[SOLVED] My LoadNextLevel isn't working fine

Im using unity 5.5.0f3 and i made some changes to my level manager, this is my actually code:

this is my emptyobject (levelmanager):

and my build settings are:
splash - 0
start - 1
win - 2
lose - 3

all work fine but when the start scene loaded something wrong is happening in the scene

[Edit] what @Rob says below.

Hello @Mario1159
Can you please post a pic of your console output?

Chris

Only had a quick look, still slightly hypnotised by the animated example…

Is your LevelManager on the Start scene? Assuming so…

LevelManager Start() method is called, that then calls the LoadStartScene() method, it ignores your AutoLoadNextLevel parameter as you don’t use it in the method, instead calling scene index 1, which is the Start scene…

…insert infinite loop here…

That’s what it looks like at a glance anyway…


Updated Thu Jan 26 2017 21:07

Sorry, just re-read and spotted the Invoke… so yes, it is using the value, just delaying the calling of the method which then loads the same scene etc…

2 Likes

yep that was my levelmanager in my startscene https://gyazo.com/20310a478a5c8818a9f4772e765bfb6e

so if i put 0 in the autoloadnextlevel there will not time to get load the scene and it will execute the scene again and again?

because if i put 2 or 1 or 10 there isn’t the error, only with the 0 but i think when will load the game scene will be returned to the start scene so… what i have to do?

Edit:
nvm i solved it xd

1 Like

So what did you do in the end @Mario1159? (may be useful for other people) :slight_smile:

1 Like

i took my old level manager (https://gyazo.com/6276cf185a12a11241f2e8c389b2f776) but i still with the same error but in lesson 133 ben solve it adding an if. :slight_smile:

Pretty useful Rob, thanks for that!

1 Like

its because the levelManager Script (Instance) is starting at the Start Scene
so I solved it like this:
I made a static bool variable called hasStarted = true;
and made an if statement at the Start() method :
if (hasStarted)
{
Invoke(“LoadNextLevel”, autoLoadNextLevel);
hasStarted = false;
}

Privacy & Terms