loading levels

hello i need help with a script i made heres what i got so far
Application.LoadLevel(0);
this works but it loads the level soon as i start the game i need the script to take me to a level i want instantly when i collide with a object i hit to i can load the next level without people knowing and i can go inside buildings i make.

pseudo-code:

function onCollisionEnter(col: Collision)
{
if (col.gameObject.tag == "HitTag")
{
Application.LoadLevel(0);
}
}

Is this what you mean? Load a level on a certain collision with an object?

As TehWut answer was wrong, heres there correct answer:

Script:

function onControllerColliderHit(hit: ControllerColliderHit)
{
if (col.gameObject.tag == "HitTag")
{
Application.LoadLevel(0);
}
}

Just a remake of that script. Thanks to TehWut!!!

  • Felipe