i made a script for a ship because i wanted to be able to destroy certain parts of it when they take enough damage, except the health variable doesn’t go down.
i can see the sparks from the bullets and they are hitting the ship and if i shoot a missile it will explode on the ship but it takes no damage.
here’s my script:
var health = 1000;
function OnCollisionEnter () {
health -= 50; //asteroids, missiles and fighters
}
function ApplyDamage () {
health -= 1; //bullets
}
function Update () {
if(health <= 0){
Destroy(gameObject); //Destroy the ship when it has no health (no explosion yet)
}
}
anyone know the problem?