GameController script has 3 separate phases - Alert Caution and Normal. As soon as Alert is activated it switches to normal which then switches to Caution. How do I fix this?

//STATUSES AND TIMERS
//
var alert : boolean;
var caution : boolean;
var normal : boolean;
var alertTimer : float = 30;
var cautionTimer : float = 30;

//CHASING
var statusGUI : GUIText;
var guardSpawn : Transform;

//var enemy : GameObject;
var enemyUnit : GameObject;
var enemyAIScript : EnemyAI;
var enemyHuntScript : EnemyHunt;

function Start(){

enemyUnit = GameObject.FindGameObjectWithTag("Enemy");
enemyAIScript = enemyUnit.GetComponent.<EnemyAI>();
enemyHuntScript = enemyUnit.GetComponent.<EnemyHunt>();


alert = false;
caution = false;
normal = true;
}

function Update(){

if(alert == true && alertTimer >= 0){
print("alert");
		caution = false;
		normal = false;
		print("CAUTION");
		statusGUI.guiText.text = "ALERT : "+alertTimer;
        alertTimer -= Time.deltaTime;
		
}else{
    	//ALERT FINISHED
    	//SWITCH TO CAUTION
    	    alert = false;
		    normal = false;
		    caution = true;
		    statusGUI.guiText.text = "";
		   }
		   
		   
		   
		   
//CAUTION
if(caution == true && cautionTimer >= 0){
		alert = false;
		normal = false;
		print("CAUTION");
		statusGUI.guiText.text = "CAUTION : "+cautionTimer;
        cautionTimer -= Time.deltaTime;
	
		}else{
		
		//
		alert = false;
	    caution = false;
		normal = true;
	    statusGUI.guiText.text = "";

		}

//NORMAL
if(normal == true){
alert = false;
caution = false;
print("Normal");
alertTimer = 30;
cautionTimer = 30;

statusGUI.guiText.text = "NORMAL";
}


}

function ActivateAlert(){
alert = true;
}

Theres the script. Bit complex but oh well. This is whats meant to happen – When alert becomes active( alert == true && alertTimer >= 0) the alertTimer counts down. When it reaches zero caution becomes true and then that counts down and then it hit’s normal. It was working yesterday but now when alert is true normal immediately becomes true and then caution becomes true. So caution is the only phase that works at the moment. I can’t figure out why(which is why I came here) and I’m a programming newb. Please help.

Try setting the alertTimer = 30 inside the ActivateAlert function as well. Assuming that you are calling it to start the whole thing off. I don’t use javascript but something like this perhaps.

#pragma strict

 //STATUSES AND TIMERS
//
var alert : boolean;
var caution : boolean;
var normal : boolean;
var alertTimer : float;
var cautionTimer : float;
var alertTime : float = 30;
var cautionTime : float 30;
//CHASING
var statusGUI : GUIText;
var guardSpawn : Transform;
//var enemy : GameObject;
var enemyUnit : GameObject;
var enemyAIScript : EnemyAI;
var enemyHuntScript : EnemyHunt;
function Start(){
enemyUnit = GameObject.FindGameObjectWithTag("Enemy");
enemyAIScript = enemyUnit.GetComponent.<EnemyAI>();
enemyHuntScript = enemyUnit.GetComponent.<EnemyHunt>();
alert = false;
caution = false;
normal = true;
}
function Update(){
if(alert == true){
   	if(alertTimer >= 0){
		print("alert");
		statusGUI.guiText.text = "ALERT : "+alertTimer;
		alertTimer -= Time.deltaTime;
	}else{
		//ALERT FINISHED
		//SWITCH TO CAUTION
		ActivateCaution();
		print("CAUTION");
		statusGUI.guiText.text = "";
	}
}
//CAUTION
if(caution == true){ 
	if(cautionTimer >= 0){
		print("CAUTION");
		statusGUI.guiText.text = "CAUTION : "+cautionTimer;
		cautionTimer -= Time.deltaTime;
	}else{
		//
		alert = false;
		caution = false;
		normal = true;
		statusGUI.guiText.text = "";
	}
}
//NORMAL
if(normal == true){
alert = false;
caution = false;
print("Normal");
alertTimer = 30;
cautionTimer = 30;
statusGUI.guiText.text = "NORMAL";
}
}
function ActivateAlert(){
alert = true;
alertTimer = alertTime;
caution = false;
normal = false;
}

function ActivateCaution(){
caution = true;
cautionTimer = cautionTime;
alert = false;
normal = false;
}

Note, I most likely made some errors because I don’t use Unity Script. But, if you call Alert via that activate this should work in theory. Hope it helps.