I watched this tutorial, but cannot figure out how to destroy my gameobject when the health bar reaches 0.
I tried this in my code (this is attached to the player) and had no luck:
void Die(){
if (ScoreManager2 .TKOCount > 2) {
Destroy (GameObject .FindGameObjectWithTag ("Player"));
SceneManager.LoadScene ("GameOver Scene");
}
if (health.CurrentValue <=0) {
Destroy (GameObject .FindGameObjectWithTag ("Player"));
SceneManager.LoadScene ("GameOver Scene");
}
}
Any help would be appreciated!