koleygr
8
Q:

detect object click unity

 
void Update()
{
  // Check for mouse input
  if (Input.GetMouseButton(0))
  {
  	Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
   	RaycastHit hit;
   	// Casts the ray and get the first game object hit
   	Physics.Raycast(ray, out hit);
   	Debug.Log("This hit at " + hit.point );
  }
}
3
 void Update () {      }  void OnMouseDown(){         // this object was clicked - do something     Destroy (this.gameObject);  }   
0

New to Communities?

Join the community