how to tell what scene the player was previously in
you have 3 lives in a 2d platformer game, with in level the player goes below those 3 lives, then goes to a death screen how can i tell witch scene he previously in, so i can teleport him back to the spawn point in the level, when he presses the retry button i am very new to unity so if the answer is obvious then am sorry.
short version: is there a way in unity to tell what scene the player was in previously
Answer by TBruce · Jun 24, 2016 at 01:29 AM
There is no built in functionality for that. The only option you really have is to save the information like in PlayerPrefs.
then how do other 2d platformers do the retry button?
There you are talking about the current scene. There are two ways to go about that.
The first is to save name of the level in a string then call Scene$$anonymous$$anager.LoadScene() something like this
string sceneToLoad = "Level 1";
Scene$$anonymous$$anager.LoadScene(sceneToLoad);
another variation of the method above is just to pass in the name as a constant like this
Scene$$anonymous$$anager.LoadScene("Level 1");
but what I prefer to do is this
Scene$$anonymous$$anager.LoadScene(Scene$$anonymous$$anager.GetActiveScene().name);
This will replay the last level played.
Your answer
Follow this Question
Related Questions
how do I make 2 player sprites not interact? 0 Answers
How to create a selectable menu off a cursor going over a game object? 0 Answers
Input.GetAxis("Vertical") not working on Mobile Phone 1 Answer
I'm currently working on a top-down shooter and I want to make shotgun 3 Answers
Win condition in minesweeper 0 Answers