- Home /
Simple Restart not working
So I have a game, and made it so if you die a death menu pops up that allows you to restart. Now I've done this before and it's very easy. I just use this line of code:
public void restart()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
I hooked that up to a button, but now for some reason, every time I press it, it restarts the scene but it restarts it with my player character in a completely different state than it should be. For some reason, my player character starts the next scene already dead if I press restart. That basically makes the game unplayable and it's really frustrating. Is there some other more advanced way to restart a scene? (I'm still pretty new to all of this.)
You very likely have a script that is not correctly behaving.
Restarting the scene does exactly the same as the first time you launch it. However there might be new elements (mouse position ? OnKeyUp? Static class with character health ? etc..) that mess with your setup you have when click the Play button in Unity.
Your answer
Follow this Question
Related Questions
Creating a Restart Button 3 Answers
i have a button to restart the same scene but it dont works (with images) 7 Answers
Simulate Button press in JS 1 Answer
How to make in main menu? 5 Answers