GameObject.Destroy(gameObject); Not Working?
So I've been following a tutorial online (I'm new to the Unity scene), and the teacher uses Destroy (gameObject); Yet every time I run it (it's supposed to destroy the character when I shoot it), nothing happens. The console doesn't give me any errors, nothing else bad happens, it just doesn't disappear. I looked it up, and someone said to do GameObject.Destroy (gameObject); instead. Still, it does the exact same thing. Am I doing something wrong here? Thanks in advance.
My Code:
#pragma strict
var Health = 100;
function ApplyDamage (TheDamage : int) {
Health -= TheDamage;
if (Health <= 0) {
Dead();
}
}
function Dead() {
GameObject.Destroy (gameObject);
}
Your answer
Follow this Question
Related Questions
Destroy GameObject after certain amount is reached? 1 Answer
Why i can't acces a global list in my class from OnDestroy() function 0 Answers
Bullets not destroying enemies 0 Answers
How to destroy object after it moves out of screen 7 Answers
Dont destroy on load is destroying my Game Manager 0 Answers