I am working on my first project in unity
In my game when i make the player dies a new level is loaded that is of game over scene
it loads game over scene correctly but when I click on the play again button it dont loads the previous level. but do executes the before and after statements of the Application.LoadLevel(“Scene_1”)
I found two solution online one is to change the indexes name in Application.LoadLevel
Another solution was to remove the static variables
I did both of them but still cant solve the problem
The scene_1 is seen after clicking the button but not completely loads the level and start the game
Can anyone help me to figure it out please
Any help will be appreciated …
What you could do is using the build numbers when adding scenes to the build manager. And create an int variable.
public int currentLevel; //Assign the current level in the inspector.
private int previosLevel;
void Awake()
{
previousLevel = currentLevel - 1;
}
void OnMouseDown()
{
Application.LoadLevel(previousLevel);
}
If your levels aren’t setup in a linear fashion, you could just do:
public int previousLevel; //Choose what the previous level was in inspector
void OnMouseDown()
{
Application.LoadLevel(previousLevel);
}