Game Over Scene

Hi

I have a game where one solve puzzles and continue to the next scene. Occasionally the player should be sent to Game Over scene, so I created a Game Over scene with a restart button.

  1. I come from a different program where you can easily just say restart previous scene and the button will understand what was the previous scene, but it seems to me that Unity don´t. Do I have to set up a Game Over scene for each level? If so how is this setup in the build? Wouldn´t it be played if it has an index?

  2. Is is possible to have a game over scene at the end of the build and Unity will just jump to start of previous scene with a button?

Hope for an answer:)

What you need is to use LoadScene from SceneManager, just feed the output of a GetActiveScene to LoadScene and your scene should reload from scratch.

I will try this:) Thanks!

Hmm. Will this work with this setup?

100 levels of 3D gameplay.
Player falls over egde of gamearea. Triggers Loadscene Game Over.
Goes to UI Game over (game over scene)
Button restart triggers beginning of previous scene.

Manage to get through scene and start next scene.
Player again dies.
Start same Game Over scene by triggering load scene Game Over
Button restart triggers beginning of previous scene. (meaning different from last time)

Hope this clears up my initial hopes of game creating:)

For something like that you might want to use an array to hold all the scene names (in order) so you can just pop back and forth between specific scenes. You just find the array element that lines up with the current scene, and then get the element that’s -1 or -2 or whatever you want and feed that into the load scene.

This sounds promising. Any chance you could make an image of the setup? Not 100 percent sure what you mean with use an array…

AOT Array of [SOMETHING] (Probably string for ease of use). Array element zero would be your first level and array element 99 would be your level 100 (arrays start at zero). One variable stores your level, so you just feed array element LEVEL-2 to the load scene. Unfortunately, i’m not in a position at the moment to build an example.