Ok so I'm running on some major BULLSHIT.
I'm trying to make that when you kill all enemies, the Win screen loads.
I have 10 enemies in the level, but for some unexplainable reason, that number just WON'T WORK.
I've tried 5 enemies or less, it works.
I've tried having 10 enemies, but let's say when EnemyCount == 9, Load the screen, and it works.
It just won't ever work with 10 enemies and until the counter reaches 0.
My code:
function OnTriggerEnter (other:Collider){
if (name == "Enemy"){
GeneralVars.nSalud+=10;
yield WaitForSeconds(.1);
Destroy(this.gameObject);
EnemyVar.EnemyCount--;
}
}
function Update(){
if(EnemyVar.EnemyCount == 0){
Application.LoadLevel("Win");
}
}
EnemyCount is a variable I set on another script called EnemyVar:
static var EnemyCount : int = 10;
I have no idea what's going on, could someone help please?
↧