Application changes???

Question:

public void LoadLevel(int lvlnum)
{
Application.LoadLevel(lvlnum);
}
This is the function I am calling to load the level however unity is saying: " Application.LoadLevel is obsolete: Use SceneManager.LoadScene

What does unity mean by this?? Where exactly do I add that code if that is the case?

i would consider it more of a 2.5d side scroller .. i want my character to kinda like travel with the projectile as if he became it and shoot himself forward

1 Answer

1

Unity now requires you to do things a bit differently.

As Unity tells you, you’ll have to use the SceneManager.LoadScene instead of Application.LoadLevel. This is done like this:

// Include the SceneManagement class
using UnityEngine.SceneManagement;

public void LoadLevel (int lvlnum)
{
    SceneManager.LoadScene(lvlnum);
}

If you want to avoid the using directive then you can also do it like this:

public void LoadLevel (int lvlnum)
{
    UnityEngine.SceneManagement.SceneManager.LoadScene(lvlnum);
}

There are plenty of available information about this and a Google search would properly have helped you as well.

Thank you so much this helped me a lot! :)

question though what about loading the current level? Say I ended the game and it said press R to restart. How what code would I use to load the current level? I have the key set up. Using the "LoadedLevel" code is obsolete

Well...? :) If you use a rigidbody to move your character, simply add the appropriate force vector to it. If using a CharacterController, move him with a CoRoutine.