Hi all, i am trying to detect a mouse click on the door and do something. Can anyone please help me see what wrong with my code snippet? it is not printing “I hit a door” and i don’t know what is happening??
var ray : Ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var hit : RaycastHit;
if(Input.GetMouseButtonDown(0))
{
//print("i click on door");
if (Physics.Raycast (ray, hit, Mathf.Infinity))
{
//door is clicked
if(hit.transform == "Door1")
{
print("I hit a door");
if(MoveAround.collect == 0)
{
nochoice = true;
}
if(MoveAround.collect > 5)
{
choice = true;
}
else
choice = true;
}
}
}