Not Working properly. Application.LoadLevel

My player has the tag of FPSController, but when I collide with the plane that has that script, the level does not change, in build settings, the next level is 2

void OnTriggerEnter(Collider other) {
	if (other.gameObject.CompareTag("FPSController")) {
		Application.LoadLevel (2);
	}
}

Current Code:

public class ToLevelTwo : MonoBehaviour {

private string[] scenePaths;

void OnTriggerEnter(Collider other) {

	if (other.gameObject.CompareTag("Finish")) {

	SceneManager.LoadScene(2);

Application.LoadLevel has been deprecated. You should be using SceneManager instead. Specifically, LoadScene

You can also use the override that takes a string to provide the name of a scene instead of the scene index, but that’s really up to you.

Current Code:

public class ToLevelTwo : MonoBehaviour {

private string scenePaths;

void OnTriggerEnter(Collider other) {

if (other.gameObject.CompareTag("Finish")) {

SceneManager.LoadScene(2);
	}
}

}

Try explicitly comparing tag. So…

If(other.gameObject.tag == “Finish”)

Make sure to Add both scene to Build on the Build settings

I had similar issues. Add a debug.log statement inside your OnTriggerEnter function and have it output a text message to the log. It doesn’t matter what it says, just trying to determine if it’s a loadscene issue, or if it’s a triggering issue. Each would have different possible causes. Let us know whether or not the debug message shows up. :slight_smile:

Stupid me, i forgot to make the plane’s collider “Is trigger”. My final script was:

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using UnityEngine.SceneManagement;

public class ToLevelTwo : MonoBehaviour {

private string scenePaths;

// Use this for initialization

void OnTriggerEnter(Collider other) {

	if (other.gameObject.CompareTag("Finish")) {

		SceneManager.LoadScene("Term Game 1");
	}
}

}