var Destination = (0);
private var controller : FirstPersonController;
@script RequireComponent(FirstPersonController)
function Start ()
{
controller = GetComponent (FirstPersonController);
}
function OnControllerColliderHit (hit : ControllerColliderHit)
{
if(Input.GetKeyUp("e"))
{
//load level
Application.LoadLevel(Destination);
}
}
Why does'nt this work?
system
2
I would use tags with gameobjects instead , and make a trigger in front of the door and use OnTriggerStay instead of colliding cause oncolliderhit is only called for one frame when the hit happens
here is some exemplary code , add this to the trigger in front of the door (untested but it should give you the idea)
var Destination ="MyLevel";
function OnTriggerStay (other : Collider) {
if(other.gameObject.tag =="Player"){
if(Input.GetKeyUp("e"))
Application.LoadLevel(Destination);
}
}
You should also use level names for Application.LoadLevel , it takes away the confusion if you have a lot of levels