Question by 
               El-Deiablo · May 11, 2016 at 02:19 PM · 
                healthbardestroygameobjectgameover0  
              
 
              Go to GAMEOVER scene when player health bar reaches 0
I watched this tutorial, but cannot figure out how to destroy my gameobject when the health bar reaches 0.
https://www.youtube.com/watch?v=RVmg6wzC-4U
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!
               Comment
              
 
               
              Is Die() ever called? And are the conditions ever met? (Score$$anonymous$$anager2 .T$$anonymous$$OCount > 2 or health.CurrentValue
Answer by Sethhalocat · Aug 10, 2016 at 08:32 PM
you could do it simply by calling die when health = 0 and have die go to the gameover scene...
 void Update ()
 {
 if (health <= 0){
 void Die();
 }
 }
 
 void Die(){
 // whatever you want here such as...
 Destroy (GameObject);
 //or SceneManager.LoadScene...
 //  hope this helps...
}
my player destroy but my healthbar does not go 0,stay on the 1
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                