Load the next level using SceneManager
Hello,
I'm almost done with my first game and it's really exciting but I'm running into an issue. I'd like to just have the next level load as soon as the boss is destroyed but rather than adding a ton of "if" statements or multiple boss scripts to change levels, I'd like the script to just go to the next level in build settings so it'd be like: If the boss of level 2 was beaten, load current level +1 so level 3...
I know Application is obsolete so I'm trying to use Scene Manager and this is the what I have
public void NextLevel()
{
SceneManager.LoadScene(SceneManager.sceneCount +1);
}
The boss script calls NextLevel from the GameController script but currently it just reloads the current level instead of moving on.
Any help would be awesome. Thank you in advance.
Try this
Scene$$anonymous$$anager.LoadScene(Scene$$anonymous$$anager.GetActiceScene().buildIndex + 1);
Yeah I had this same problem but the answer script worked :)
Answer by castingflame · Feb 03, 2017 at 01:47 PM
Please do not take offense but there is a typo:-
SceneManager.LoadScene(SceneManager.GetActiceScene().buildIndex + 1);
should be
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
but thanks. It help me out too :)
Your answer
Follow this Question
Related Questions
i need help with enemy respawn 0 Answers
How Can I Open Previous Scene? 1 Answer
How to access variables in another scene? 2 Answers
1 Restart Scene multiple levels. Is this possible? - C# - 1 Answer