Hi,
I want to retrieve the name of this gameObject on my scene when I click on an object in order to execute an animation but I can not do it. My click return nothing.
Code :
// Builds a ray from camera point of view to the mouse position
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
// Casts the ray and get the first game object hit
if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask))
return hit.transform.gameObject;
else
return null;
Do you have an idea of the problem ? I attach this script on my gameObject (a Door)
Thanks