I made a door opening script in unity That's the code of it:
void Update () {
if (i < 5)
{
if (Input.GetMouseButtonDown(0))
{
transform.Rotate(Vector3.up * Time.deltaTime * 1080);
i++;
}
}
else if (i >= 5)
{
if (Input.GetMouseButtonDown(0))
{
transform.Rotate(Vector3.down * Time.deltaTime * 5400);
i = 0;
}
}
}
The problem is that action take place when I click the mouse everywhere and everytime. I want to make it happen only when I click the door.