var enemyUnit = GameObject.FindGameObjectWithTag("Enemy");
var enemyAIScript = enemyUnit.gameObject.GetComponent(EnemyAI);
function Start(){
alert = false;
caution = false;
normal = true;
}
function Update(){
if(alert == true && alertTimer >= 0){
caution = false;
normal = false;
statusGUI.guiText.text = "ALERT : "+alertTimer;
alertTimer -= Time.deltaTime;
enemyAIScript.SendMessage("HuntTelic");
enemyAIScript.go = false;
}
The error it give in the editor is : UnityException: You are not allowed to call this function when declaring a variable.
Move it to the line after without a variable declaration.
If you are using C# don't use this function in the constructor or field initializers, Instead move initialization to the Awake or Start function.
ControlAI..ctor () (at Assets/BLAM/Enemies/RegularUnits/ControlAI.js:13)
.
If I put the variables in Start the update function doesn't recognize them. If I put it in update for some reason the rest of the script doesn't work . I don't have anywhere else to put it. What do I do ?
PS I didn't post the whole script. var enemyUnit is line 13 in the full script
↧