Answers for "RaycastHit2D get mouse hit object unity"

C#
0

mouse click unity raycast unity

if ( Input.GetMouseButtonDown (0)){ 
   RaycastHit hit; 
   Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); 
   if ( Physics.Raycast (ray,out hit,100.0f)) {
     StartCoroutine(ScaleMe(hit.transform));
     Debug.Log("You selected the " + hit.transform.name); // ensure you picked right object
   }
 }
Posted by: Guest on February-25-2021
1

raycasthit2d unity

RaycastHit2D hit = Physics2D.Raycast(transform.position, -Vector2.up);
Posted by: Guest on February-15-2021

C# Answers by Framework

Browse Popular Code Answers by Language