Answers for "why raycast is not hitting a 2d object unity"

C#
2

why raycast is not hitting a 2d object unity

//Have to use 2D version in 2D scenes.
 //Object must have a collider.
 RaycastHit2D hit = Physics2D.Raycast(transform.position, Vector2.down);
         if ((hit.collider != null) && (Input.GetMouseButtonDown (0))) 
         {
             print ("This hit at " + hit.collider.name);
         }
Posted by: Guest on May-21-2020

C# Answers by Framework

Browse Popular Code Answers by Language