Question by
Unity_GEAR · Jul 19, 2021 at 05:27 PM ·
scene-loadinghealth
Why isn't the scene resetting even when my players health reaches 0?
When the player's health reaches zero, it's supposed to reset the current scene instead it just keeps on losing health and the scene stays the same. Please let me know what the issue is.
public int health = 100;
public void TakeDamage(int damage)
{
health -= damage;
if (health <= 0)
{
ResetScene();
}
}
public void ResetScene()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
}
Comment
I believe it is because the current scene is already loaded...i don't know how to fix this however
Your answer
![](https://koobas.hobune.stream/wayback/20220613040528im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Making a potion class (change values two objects down) 0 Answers
Cant add to int from another script? 2 Answers
OnCollisionEnter2D not working, Again! 0 Answers
Annoying Quaternions and Eulers 1 Answer
Cache Server Error 0 Answers