//STATUS
var alert : boolean;
var caution : boolean;
var normal : boolean;
var alertTimer : float = 30;
var cautionTimer : float = 30;
//CHASING
var statusGUI : GUIText;
//var telicLocation : Transform;
var guardSpawn = Transform;
var enemy : GameObject;
var enemyUnits;
var enemyAIScript;
function Start(){
enemyUnits = GameObject.FindGameObjectsWithTag("Enemy");
enemyAIScript = enemyUnits.gameObject.GetComponent("EnemyAI");
alert = false;
caution = false;
normal = true;
}
function Update(){
if(alert == true){
print ("alert");
caution = false;
normal = false;
print("ALERT");
statusGUI.guiText.text = "ALERT : "+alertTimer;
alertTimer -= Time.deltaTime;
enemyUnits.gameObject.SendMessage("HuntTelic");
enemyAIScript.active = false;
**if(alertTimer <= 0){
alertTimer = 0;
alert = false;
normal = false;
caution = true;
}**
}
if(caution == true){
alert = false;
normal = false;
print("CAUTION");
//Instantiate(enemy, guardSpawn.position, guardSpawn.rotation);
//Instantiate(enemy, guardSpawn.position, guardSpawn.rotation);
enemyAIScript.active = false;
statusGUI.guiText.text = "CAUTION : "+cautionTimer;
cautionTimer -= Time.deltaTime;
if(cautionTimer <= 0){
alert = false;
caution = false;
normal = true;
}
}
if(normal == true){
alert = false;
caution = false;
statusGUI.guiText.text = "";
enemyAIScript.active = true;
}
}
function ActivateAlert(){
alert = true;
}
Apologies if my script is hard to understand or convuluted. This script is for the game to determine what state the enemies are in - Alert Caution or Normal. If it’s in alert a timer will countdown from 30. After it hits 0 the enemy state is meant to change to caution. This is meant to change the timer back to 30 with the words caution instead of alert. The part of the script that doesn’t work is the highlighted part in bold. Instead of resetting the timer keeps counting down and going into the minus numbers while it stays in the alert state.
Anyone have any ideas how to fix this? Again the part that needs fixing is the bold section where the if else statement is. Thanks in advance - Stealth.