- Home /
Application.LoadLevel not working
This is a basic JavaScript I am trying to use in a platform so that when the player touches it, the level will change.
function OnTriggerEnter( other: Collider)
{
Application.LoadLevel("Level_2");
}
But nothing happens when the player touches the platform, no matter which collider is set to Trigger.
Is this on the platform, or the player? Do you have Level_2 defined in your build (and since you are using string, exactly named "Level_2"? If all that's setup and you still aren't getting the transition, your Trigger isn't firing - do you have layers configured?
Typically a trigger has something like this in it if(other.tag == "Player") // do stuff
so that a random thing hitting the trigger (ie not a Player) won't fire the event
add a print or console.log statement to test if it is triggering, if not, do what getyour411 said. In addition i would add a rigidbody to the platform, and the player if it doesn't have one. things can get unpredictable if rigidbodies are not attached to the objects you want to detect collisions with.
Answer by elopez7 · Mar 14, 2014 at 01:21 AM
Check your build settings and make sure that Level2 scene is added to the project. Now if that does not work, check what number is assigned to your scene in the Scenes to build list in the build settings menu.