how can i reload the last level when i collide with the wall
at the moment i can’t do anything
how can i reload the last level when i collide with the wall
at the moment i can’t do anything
function OnCollisionEnter (collision : Collision) {
if (collision.gameObject.name==“wall”)
Application.loadLevel(Application.loadedLevel);
}
#pragma strict
private var NL = false;
function OnControllerColliderHit(hit:ControllerColliderHit) {
if(hit.gameObject.tag == “NextLevel”)
{
Debug.Log( hit.gameObject.tag );
yield WaitForSeconds (3);
NL = true;
} }
function LateUpdate() { if(NL) {
Application.LoadLevel(0);
NL=false;
}
}
be sure to set the tag right !!! (spelling also) 2: be sure to set the level you want to load to the number 0 in the build settings under file.
but … you don’t need the : yield WaitForSeconds (3);
you can use it if you want it to wait 3 seconds before loading the other level.
found at Collision load level - Questions & Answers - Unity Discussions