Enemy health (648912)

I need help with my java i have used this script to destroy the enemy when health is = to or under 0

#pragma strict

var Health = 100;

function Update ()
{
if(Health >= 0);
{
Destroy(gameObject);
}
}
function ApplyDammage (TheDammage : int)
{
Health -= TheDammage;
}

the destroy game object is running instantly and killing of the enemy before the health has bean reduced basically. dose anyone know how to solve it if so you can either email me at onefishykid2015@gmail.com or post back on these forums it will be greatly appreciated thank you.
there is another script By the way that inflicts the damage and it dose reduce health from 100 to 50 to 0. i tested without the destroy game object in and it worked

Ask yourself, what does " >= " stands for ?

1 Like

= is greater than, you want <=

1 Like

i tried it the outher way around and still dose the same

Then there is another underlying problem.
When is ApplyDamage being called. OnCollisionEnter? OnTriggerEnter?
Please for the love of god learn how to debug. Add a Debug.Log() to the ApplyDamage method so you can actually track when things take damage and for how much.

3 Likes