Health,End Game Panel and Gave Over Text
I have a levelmanager that holds the player health
[Header("Player Health")]
public int maxHealth = 7;
public int currentHealth = 7;
When I then created a Canvas UI Plane and Text for Game Over. and I have attached it to the levelManager.
But, when the player life gets to zero, nothing happens
public void PlayerGameOver()
{
if (currentHealth <= 0) {
GameOverText.gameObject.SetActive (true);
Time.timeScale = 0;
EndGame.gameObject.SetActive (true);
}
}
The player currrent health does deplete in game, but never get the game over messages. Where am I going wrong?
Are you calling PlayerGameOver() somewhere in your code?
I figured it out. Basically I had two scripts that deal with health. One is for the health itself and the other is for a health bar. both are controlled by the level manager. I was not tying everything together. By thank you for replying.
Your answer
Follow this Question
Related Questions
How do I make ending credit in Unity C# 1 Answer
How do I make my healthbar change color depending on damage? 1 Answer
does someone have a player health script and a way to make a health bar? 0 Answers
My health bars image.fillAmount doesnt change. 4 Answers
Healthbar system not working correctly 0 Answers