title: Loading next level Unity c#
body: <p>Heres my first attempt at loading the next level upon reaching "Goal"</p>
  
  <pre><code>public int CurrentLevel = 0;
  public static int maxlevel = 3;
  
  public void CompleteLevel()
  {
      if (CurrentLevel &lt; maxlevel)
      {
          CurrentLevel += 1;
          SceneManager.LoadScene(CurrentLevel);
      }
      else
          print("you win");
  }
  </code></pre>
  
  <p>This is in another class...</p>
  
  <pre><code>void OnTriggerEnter(Collider other)
  {
      if (other.transform.tag == "DeathObject")
          Die();
      if (other.transform.tag == "Goal")
      Manager.CompleteLevel();
  }
  </code></pre>
  
  <p>It ended up loading the first level, went to the second, then it would repeat the second map when i reached goal. Another thing it would do is skip to the last level from the first or second level.. not sure whats going on there. Heres the second thing i tried:</p>
  
  <pre><code>public void LevelPassTest()
  {
      if (Application.loadedLevel &gt; 4)
          Application.LoadLevel(Application.loadedLevel + 1);
          else
      print("win");
  }
  </code></pre>
  
  <p>This is in another class....</p>
  
  <pre><code>void OnTriggerEnter(Collider other)
  {
      if (other.transform.tag == "DeathObject")
          Die();
      if (other.transform.tag == "Goal")
      Manager.LevelPassTest();
  }
  </code></pre>
  
  <p>I'm not sure why, but sometimes it doesn't load the next level, it worked for a while then stopped, after I reset unity it works again, so I'm not sure if it's my code or unity... I get a warning message that says "Warning  CS0618  'Application.loadedLevel' is obsolete: 'Use SceneManager to determine what scenes have been loaded'" and "Warning   CS0618  'Application.LoadLevel(int)' is obsolete: 'Use SceneManager.LoadScene'" I'm new to coding and completely lost on this. spent 4 hours trying to fix it. What are these warnings? can they be effecting the loading? I was also wanting to be able to save the value of the level so i can use it in game saves, and attach high scores to it. I tried using this in my first attempt, but it didn't work how i was hoping. (CurrentLevel)</p>