system
1
Basically, I want to load a level when a collision happens. "Runner" is the player, a FP controller. Where am I going wrong?
var myLevel : String;
function OnCollisionEnter (theCollision : Collision) {
if(theCollision.gameObject.name == "Runner"){
Application.LoadLevel(myLevel);
}
}
Thanks.
Have you added the scenes you want to be able to load to build settings?

system
3
change Application.LoadLevel(myLevel)
to Application.LoadLevel(0)
don't change anything in the build settings (you can but it's not needed
If you're dealing with a character controller, then you should use OnControllerColliderHit.
var myLevel : String;
function OnControllerColliderHit (hit : ControllerColliderHit)
{
if (hit.gameObject.name == "Runner")
{
Application.LoadLevel(myLevel);
}
}
system
5
var myLevel : String;function OnControllerColliderHit (hit : ControllerColliderHit){ if (hit.gameObject.name == "Runner") { Application.LoadLevel(myLevel); }}