X-ray detection in Unity

Source: Internet
Author: User

Unity's radiographic testing

Raycasthit hit; Storage of information after radiographic inspection

if ( physics.raycast (transform.position + vector3.up * 0.3f, Transform.forward, out hit, 5f))//radiographic inspection The return value is a bool value, the first parameter: the ray start position; The second parameter: the direction of the Ray (Transform.forward is the z-axis direction of the script object); the third parameter: storing the detection information in hit, of course and maxdistance: The maximum length of the ray; the fifth parameter: int layermask: A layer of ray detection.
{
if (hit.collider.tag = = "Obstacle" && speed >= 3&&anim. Getcurrentanimatorstateinfo (0). Isname ("Locamation"))
some common methods of//raycasthit
{

Vector3 point = hit.point;

Point.y = hit.collider.transform.position.y + hit.collider.bounds.size.y;
Matchtarget = point;

}


}

}

Flexible application of radiographic testing

If (Input. Getmousebuttondown(0)) {

Raycasthit hit;Ray Ray .= Camera.Main.Screenpointtoray(Input.mouseposition);// Ray detection and camera mouse with the use of  if (Physics.  Raycast(Ray, out hits  )) if (hit.  Collider = null) hit.  Collider.  Enabled = false;               

}

X-ray detection in Unity

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.