- Home /
enemy is destroyed at the start instead of when health is 0
heres my script
var health = 2;
function Update() {
if (health <= 0);
Invoke ("Die",0);
}
function ApplyDamage () {
health -= 1;
}
function Die() {
Destroy (gameObject);
}
the enemy is destroyed at the start instead of when it has 0 health, also i have another script which sends ApplyDamage when the enemy gets hit
Comment
If damage is only applied via the ApplyDamage function, you can just check the health there ins$$anonymous$$d of using Update().
Answer by Default117 · Nov 22, 2011 at 04:13 AM
Try getting rid of the semi colon after the if statement. if (health <= 0);