How do I finish a level and send the player to the next?

How do I finish a level and send the player to the next? I have been making a 2D platformer (following the tutorial on the website), but it never explains what to do if you want to get the player to the next level.

Should the next level be in a different scene, or should it warp the player somewhere else? Can someone give me tips for this? - This has been solved. I'm doing a different scene.

Also, what script can be used to move the player and respawn point from the finish object in the level to the next starting point of the next level? How do I use it? - I've figured that out. I just have to duplicate the objects there.

I've also got a fanfare I'd like to play at the end of the level. How can I add that in there as well?

Thanks if you can help!

Putting your next level in a new scene can simplify the process of progressing to a new level and also help keep the performance of your game up by having less complicated scenes to deal with. However, it can make returning to a completed state in an old level more complicated.

The transition can be done with a Trigger Collider that has code similar to this (c#):

OnTriggerEnter(Collider other)
{
    if (other.tag == "Player")
        Application.LoadLevel("NameOfNextScene");
}

If you have information that you need to save between levels, consider placing it in static variables/classes, or having a GameObject that is set to gameObject.DontDestroyOnLoad() so it is not removed when the new scene is loaded

As far as player spawn position, simply place the player into the position they should start at in the editor for the new level (in much the same way as you did for your first level)

Sorry, moved to comment section.

karl wrote here: Move to next level on collide


Here's a completed script allowing you to set the next scene in the inspector. Make sure the plane/object you walk in to has "Is Trigger" marked. No rigidbody necessary.

//Script to revert winning player back to main menu

var levelToLoad : String;

function OnTriggerEnter(hit : Collider)
{
Application.LoadLevel(levelToLoad);

}//END FUNCTION ONTRIGGERENTER


This answers the question.