I want the player to enter a “password” when asked to in one of my minigames.
This password is selected from a string by using the following code:
public string GetRandomPassWord(){
return Passwords[Random.Range(0, Passwords.Length)];
}
This is of course working as intended.
Then, I want to check if the last selected password is the same as the new one, but that isn’t working correctly yet. What should I change in the following code to fix it?
correctPassword = GetRandomPassWord();
if (lastPass != "") {
if(lastPass == correctPassword){
correctPassword = GetRandomPassWord();
Debug.Log ("Was last pass!");
} else {
lastPass = correctPassword;
}
} else {
lastPass = correctPassword;
}