- Home /
Level Softlocks when loaded
Hello,
I have a problem on when I complete a level in my game and when it goes to the next one, in the hierarchy it states that the level is loading back and forth with the loading scene. I don't know what is causing this to happen or how to fix it.
In addition, I looked at the script that loads the scenes in and it works normally since it's the same one being used in my Main Menu
Are you loading your scene asynchronously? If yes try LoadScene ins$$anonymous$$d.
Answer by unity_ek98vnTRplGj8Q · Jan 07, 2020 at 04:33 PM
This often happens when you are accidentally loading your scene repeatedly. Make sure the call to load the scene gets called only once, and that whatever trigger you use to signal a new scene load isn't triggering immediately once a new scene is loaded again.
How do I find where it is repeatedly calling the function telling to load the level? I'm looking in the spots where the I call "LoadNextScene" but they're in the right places that I see.
Well, how should we tell you where in your code (which we don't know) you load the level again? Unity does not load any level automatically except the first level and this only once at startup in a build.
Since you have some DontDestroyOnLoad objects in your scene / old scene I see two possible reasons:
First you might have a persistant script from the last scene which does load the scene over and over again.
Second you might have a script inside the newly loaded scene which causes the scene to be reloaded.
We can not check any of those things since we have no idea what your scripts look like and where those scripts are attached to.
Please edit your question and add the relevant code if you still need help with your issue. Otherwise debugging your project is up to you. Again this is not a Unity issue, this is an issue in your code. We don't play "guess my error" here.
I think you might be on to something. I'll check my Game$$anonymous$$anager Script since that the main script that has DontDestroyOnLoad function on it and see if that might be the root of the cause.
Your answer
Follow this Question
Related Questions
How Do I Link Different Scenes? 4 Answers
Change Scene keeping Character and GUI Canvas 1 Answer
Scene Loading Issue. 0 Answers
Can't find game object / script after scene re-enter 1 Answer