- Home /
Next scene not loading
using UnityEngine;
using UnityEngine.SceneManagement;
public class levelComplite : MonoBehaviour
{
public void LoadNextLevel()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
}
I have got both scenes ticked on the build settings and I have an event that calls on this script but when I run this code it does not load the next the next scene it loads the same level can anybody help me.
The function seems to be ok, but did you attach this script to some object in the scene? if yes then how are you calling this function can you show that?
Answer by puckloe · Apr 11, 2019 at 01:59 PM
I figured it out. It was not how I called the script that was the problem the problem was that after the player reached the end of the level as it is an auto move game then it went of the ground and fell causing a game over to be triggered so to fix it I added a block to stop it from falling of.
Answer by haizathaneefa · Apr 11, 2019 at 08:06 AM
Tested your script. It works fine. Just be sure to attach the script to a gameobject in the scene. Probably the way you call the script from another that is causing it. Would be appreciated if you provide the way you call the script.
I'm the college life student and facing the same problem in my project, and get to knwon that i'm getting this due to another script becaude of it i'm facing problem in my loading of next level.
So your problem is dealt with now? or are you still facing some errors?
Your answer
![](https://koobas.hobune.stream/wayback/20220612195238im_/https://answers.unity.com/themes/thub/images/avi.jpg)