load level on collision

how can i reload the last level when i collide with the wall

Collision picture:

at the moment i can’t do anything

function OnCollisionEnter (collision : Collision) {
if (collision.gameObject.name==“wall”)

#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) {



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