I’m developing a game which involves teleporting between different rooms. There are 3 rooms. I’m trying to make it so when you’re in the third room (room == 3), you can’t teleport that direction a fourth time. Same with if you’re in the first room.
Here is my code:
var room = 1;
function Update ()
{
if(Input.GetButtonDown ("E")){
transform.position.z += 23.7587996;
room+=1;
}
if(Input.GetButtonDown ("Q")){
transform.position.z += -23.7587996;
room+=-1;
}
}
}
Is there some sort of if-then statement I can use to achieve this?