Unity Doesnt Load Next Levels

I have set up my game to where a player goes into a cube and when they reach the cube, they enter the next level/scene in the build settings, but no matter how i put the code, it doesn’t work the way I want it to.

public class GameManager : MonoBehaviour {
    public static int currentScore;
    public static int highScore;
    public static int currentLevel = 0;
    public static int unlockedLevel;





    public static void CompleteLevel ()
    {

        Application.LoadLevel(currentLevel + 1);

    }
}

^This Code takes me from level 1 to level 2, but once it gets to level 2, it stops proceeding.^

using UnityEngine;
using System.Collections;

public class GameManager : MonoBehaviour {
    public static int currentScore;
    public static int highScore;
    public static int currentLevel = 0;
    public static int unlockedLevel;





    public static void CompleteLevel ()
    {

        Application.LoadLevel(currentLevel += 1);

    }
}

^This code will take me to level 1, then two, then two again, then four.^

The Difference between the two codes is “Application.LoadLevel += 1”

I was wondering if somebody could help me make it so it goes level 1, 2, 3, 4, 5, 6 and so on.
Thanks!

You’ll need to post more complete code. Where are you calling the CompleteLevel() function from? Is this GameManager class a singleton?

Just realized I posted this in Graphics. Oops.

I’m a beginner so I don’t know all the slang like singleton lol.

But the CompleteLevel() is called in the playerMovement script when the player arrives at the square tagged “Goal”
Lines 40-46

using UnityEngine;
using System.Collections;

public class PlayerMovement : MonoBehaviour {
    public float moveSpeed;
    private float maxSpeed = 5f;
    private Vector3 input;
    private Vector3 spawn;
    public GameObject deathParticle;
    public float deathHeight;
    // Use this for initialization
    void Start () {
        spawn = transform.position;
    }
  
    // Update is called once per frame
    void Update ()
    {
        input = new Vector3 (Input.GetAxisRaw ("Horizontal"), 0, Input.GetAxisRaw ("Vertical"));

        if (rigidbody.velocity.magnitude < maxSpeed)
        {
            rigidbody.AddForce (input * moveSpeed);
        }
        if(transform.position.y < deathHeight)
        {
            Die ();
        }
    }
  

    void OnCollisionEnter(Collision otherCollision)
        {
        if( otherCollision.gameObject.tag == "Enemy" )
        {
            Die();
        }
    }
        void OnTriggerEnter(Collider other)
    {
        if (other.transform.tag == "Goal") {
            GameManager.CompleteLevel();
       
        }
        }

    void Die()
    {          
        Instantiate(deathParticle, transform.position, Quaternion.identity);
            transform.position = spawn;
    }
        }

I’m guessing your GameManager is recreated with every level if you don’t make it stick around through some other class. This tutorial has a way to make it a singleton: http://unity3d.com/learn/tutorials/projects/2d-roguelike/gamemanager

Now that’s funny right there!

It would be better to have your gamemanager a singleton; however as a quick fix, assuming you are using sequential level numbers:

Replace:

Application.LoadLevel(currentLevel +1);

With:

Application.LoadLevel (Application.loadedLevel + 1)