Loading level Error? :(

Hey guys im having a problem when trying to load my level, im New so i tried to make it wait 5 secs before loading the map but its coming up with errors lol.

function Update () {


 yield return new WaitForSeconds(5);
        Application.LoadLevel(0);

}
}

As of yet, there’s no error information provided which makes the question particularly difficult to answer but a common issue I’ve ran into in the past has been forgetting to add it to the level list.

Per Unity documentation:

“Before you can load a level you have
to add it to the list of levels used
in the game. Use File->Build
Settings… in Unity and add the
levels you need to the level list
there. MonoBehaviour.OnLevelWasLoaded
is called on all active game object’s
after the level has been loaded.”

Well, yes, that would have a problem. You put it in Update, which means that, every frame, it’s being told to wait for five seconds.

Try this:

function Start () {
  Invoke("LoadLevel", 5);
}

function LoadLevel () {
  Application.LoadLevel(0);
}