live system not working when player dies it decreases by 2, eg, 3, 1, -1 then the players lives is over
// Use this for initialization
void Start () {
thePlayer = FindObjectOfType<PlayerController>();
coinText.text = "Coins: " + coinCount;
healthCount = maxHealth;
objectsToReset = FindObjectsOfType<ResetOnRespawn>();
currentLives = startingLives;
livesText.text = "Lives x " + currentLives;
}
// Update is called once per frame
void Update () {
if(healthCount <= 0 && !respawning)
{
Respawn();
respawning = true;
}
}
public void Respawn()
{
currentLives -= 1;
livesText.text = "Lives x " + currentLives;
if(currentLives > 0)
{
StartCoroutine("RespawnCo");
} else {
thePlayer.gameObject.SetActive(false);
}
}
here is my code, I want it to go like this, 3,2,1 but it's going down like this 3,1,-1. Anyone any ideas why this is happening?
Comment
Your answer
Follow this Question
Related Questions
Please help me to solve this in unity C# scripts (TriggerCounter and OnTriggerEnter) 0 Answers
How can I display the number of times a gameobject has been clicked? 1 Answer
Why do I keep getting a null reference? Its not null! 0 Answers
How To Make A Kill Counter 1 Answer
How to create a step counter. 0 Answers