Question by
elcamp3 · Jul 11, 2018 at 05:48 PM ·
scripting beginnerelseelse if
Flipping Switches
I want to set up a system in which a number of switches have to be activated in a certain order to activate the door. Example -- There are five switches in a room, and the player has to flip them in the right order to get access to the next room. Is this possible through an else-if function?
Comment
Best Answer
Answer by KureKureciCZ · Jul 11, 2018 at 07:30 PM
Make a progress variable, and in each point check what is being switched next.
something like:
int progress = 0;
void OnSwitcheSwitched{
if(progress == 0){
if(switch1 == true)
progress++;
else
progress = 0;
}
if(progress == 1){
if(switch3 == true)
progress++;
else
progress = 0;
}
...
}