x


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

more ▼

asked Nov 22 '11 at 04:00 AM

sam32x gravatar image

sam32x
178 42 57 63

If damage is only applied via the ApplyDamage function, you can just check the health there instead of using Update().

Nov 22 '11 at 08:07 AM kevork
(comments are locked)
10|3000 characters needed characters left

1 answer: sort newest

Try getting rid of the semi colon after the if statement. if (health <= 0);

more ▼

answered Nov 22 '11 at 04:13 AM

Default117 gravatar image

Default117
346 26 30 33

oh thats it thanks

Nov 22 '11 at 04:16 AM sam32x
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3419
x57
x11

asked: Nov 22 '11 at 04:00 AM

Seen: 634 times

Last Updated: Nov 22 '11 at 08:07 AM