Loading a Level

I’m trying to make a 2d platform, and I want to make a Loadlevel script that when the player gets within a certain distance of a teleport platform, it will load the next level. So that being said, I understand it will require a raycast to find the player, and then a Application.LoadLevel(“Level2”); can anyone help me out with putting it all together?

It shouldn’t require a raycast (using a trigger would be a more typical solution).

Well you can do what I did, I made a case statment and tagged my level exits something diffrent for each case here is some of the script:

//Exit level functiion
function OnControllerColliderHit (hit : ControllerColliderHit)
{
switch (hit.gameObject.tag)
{
case “LevelExit1”:
Application.LoadLevel(2);
break;
}
}

After that you would use a new tag such as “LevelExit2” And that case would make it load level 3