im trying to get my game to switch back and forth between modes.
public GameObject attack;
public GameObject defense;
public int shift;
// Use this for initialization
void Start () {
int shift = 1;
attack.SetActive (true);
defense.SetActive (false);
}
void Update ()
{
if (Input.GetButton ("Fire2") && shift == 1) {
attack.SetActive (true);
defense.SetActive (false);
shift = shift + 1;
}
else if (Input.GetButton ("Fire2") && shift == 2) {
attack.SetActive (false);
defense.SetActive (true);
shift = - 1;
}
}
but the code only switches the mode from 1 to 2 and it wont switch it back