- Home /
Can I detect detect if I clicked on same spot which is enlighted by spotlight?
Hi, is there any posible way how to detect if I am click on part of 3d object which enlighted by spotlight?
I use this code to detect if i clicked on object, but I cant find any way to detect if i clicked on same spot which is enlighted by spotlight.
public Camera cam;
void Start () {
}
void Update()
{
if (Input.GetMouseButtonDown(0))
{ // if left button pressed...
Ray ray = cam.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
print("hit object");
}
}
}
Comment
$$anonymous$$aybebyou need to do it via diferent way.
Using event system/event trigger component in the object you want do detect
Bye