Question by
zain4 · Aug 06, 2016 at 12:55 AM ·
scripting problemraycastingunity 4.6game object
i am making an increment of one when user clicks a game object, trying to decrement the counter if the same game object is clicked again. here is my code
void Update() { if( Input.GetMouseButtonDown(0) ) { Ray ray = Camera.main.ScreenPointToRay( Input.mousePosition ); RaycastHit hit;
if( Physics.Raycast( ray, out hit, 100 ) )
{
if( hit.transform.gameObject.name == "answer" )
count++;
print(count);
}
}
}
Comment