Changing level with Collider....

Hello unity friends, I am working on a game that is first person. I want it so that when my player runs in to a certain area or touches a cube it changes levels… I have this script that is not working and unity keeps giving me a error saying -

Script error: OnTriggerEnter
This message parameter has to be of type: Collider
The message will be ignored.

How do I fix this error I really don’t know what to do… I have been looking online and no one really has the same problem I do.

function OnTriggerEnter(hit : Collision)

{
if (hit.gameObject.tag == “Player”)

{Application.LoadLevel (“Maze2”);}

}

Ok so the way I would go about this would to be to add a trigger collider on the cube by simply checking is trigger in the collider component on the cube, I would then tag the cube as something (This can be found at the top just above the transform options) e.g. levelAdvancer I would then add the code below to the graphics of the first person controller (The cylinder bit). PS. You need to make a new level by going ‘File > New Scene’ You may then build your level here, And then go ‘File > Build Settings’ and press add current to create a level (note this should be level 1). Done This should work for you now. PPS. You can go back to your old scene at any time, it will be located in your assets folder on the project panel.

function Start()
{
         Application.LoadLevel(0); //loads level 0
}


//your other code...



function OnTriggerEnter(other : Collider) //if the player is in a trigger collider 
{
        if (other.CompareTag("levelAdvancer")) //if player is touching the cube.
        {
                Application.LoadLevel(1); //loads level 1
        }
}

//*This Code Is Untested So please Don't Be Angry If It Does Not Work*

Alright, if you’re using the first person controller from Standard Assets then this should be fairly easy.

var SceneToLoad : String; 

function OnTriggerEnter(hit : Collision)
{ 
  if (hit.gameObject.tag == "Player"){
     Application.LoadLevel (SceneToLoad);
  }

}

This way you will be able to edit the scene in the inspector which should simply be Maze2.

First thing, make sure your first person controller has a tag attached that says Player, note layer and tag are different.

Second thing, make sure you’re object that is going to have this script has a collider with a Is Trigger enabled.