- Home /
Application.Loadlevel loads incorrect scene.
Okay, so I'm making my first Unity project as a college thingy. At any rate, I made a simple 2D platformer with a single level. During said level there are hazards that, when touched, take the player to a "Game Over" scene (which, in turn, takes them to the main menu). That is working properly. My problem comes when the player reaches the goal (aka the end of the level) and the script there should send them to another scene called "The End" but instead calls "Game Over". Some things of note are: - I am using only strings to ID the scenes, though I tried using integers and nothing changed; - Any valid string or integer that I put into the ending script's Loadlevel takes the player to "Game Over"; - Every other Loadlevel in my project is working 100% fine.
Just throwing out ideas here, but are you sure theres not something triggering the game over just before the victory script, perhaps a case you didn't think of? Perhaps the end point itself is a type of "hazard" or something. Or has the hazard script attached to a child?
Is this happening in the editor or just the deployment? Its possible to not include some scenes when you build, although I think if you try to load a level that isn't there you'll just get an error.
I'm pretty sure it's not being triggered just before it because the scrip that calls for the "Game Over" scene is only attached to a prefab. I used an entirely new object to make the end goal (with an entirely new script as well). Also, I didn't put the end goal as a child to anyone. When you mention deployment I have to admit I didn't try building and running it yet (so all my experience with it is within the editor). Should I try to Build & Run to see if it'll work nonetheless? Oh! Another important detail I forgot to add: When I disable the "Game Over" scene in the Build Settings, the end goal properly loads the "The End" scene.
Your answer
![](https://koobas.hobune.stream/wayback/20220613103319im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Load Scene from within folder? 2 Answers
My button won't load a scene 1 Answer
SceneManager.GetAllScenes() only returns the current scene 3 Answers
,Enums not being passed between scripts properly 1 Answer
How do I reset part of a scene? 1 Answer