So i’m trying out a tutorial on how to use unity, and I’ve run into a problem. I’m trying to use Input.GetMouseButtonDown(0) to detect when the mouse button has clicked on either blank space or an object, but no matter what it will only detect 2 clicks total (one for not hitting an object, and one for hitting one). Here is the code I’ve got:
function Update()
{
//want to use the left mouse button to select on
//game objects in the scene
if(Input.GetMouseButtonDown(0))
{
print("Yes the button works");
var hit : RaycastHit;
var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if(Physics.Raycast(ray, hit, 100.0))
{
print("You hit an object");
}
}
}
Has the way that GetMouseButtonDown(0) works changed? or is there something i’m missing in my code here (also, the tutorial I’m following is here: 5 03 scripting player raycast on Vimeo in case that helps)