I attempted the challenge a different way, and it never looped back to level 1

Apologies for sending an image and not the code, but as it’s just a short method. When i did it this way it never looped back, i have now done it the way of the video but i am curious as to why this never worked? any ideas? Thanks

I did it like this…

private void LoadNextLevel()
{
int nextSceneIndex = SceneManager.GetActiveScene().buildIndex + 1;
if (SceneManager.sceneCountInBuildSettings > nextSceneIndex)
{
SceneManager.LoadScene(nextSceneIndex);
}
else
{
LoadFirstLevel();
}
state = State.Alive;
}

Then make sure all your scenes are in the build settings and in the order you want.

Privacy & Terms