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);
}
}
}