[Solved] Exit scene OnCollisionEnter not working

I’m new to Unity (so i don’t really know how to script properly) and i’m trying to do a FPS game. Everything works fine except that the script i’m trying to use to exit the application doesn’t work. I’ve been looking through the forums and nothing seems to work. I know i’m doing something wrong but can’t tell why; any help will be welcome.

The cube (goal) i’m using has a box collider with “Is trigger” unchecked and no other scripts attached. The character doesn’t have a collider, but it detects platforms and walls, so i don’t think this is the problem.

This is the script i’m using (javascript):

function OnCollisionEnter(collision : Collision) {
	
        //Will display if collision was detected
	print("Worked");

        //Exits the game
	Application.Quit();

}

Thanks for the help! :slight_smile:


The script that solved my problem (thanks to darker9999):

function OnTriggerEnter (other : Collider) { 
     print("Worked");
     Application.LoadLevel(0);
}

Cube(goal) is a rigidbody with Gravity unchecked, has a box collider with IsTrigger checked
Graphics(Character) has a CharacterController

Hi TheFFFUUUguy,

Application.Quit() not working on editor, if you run your application on device after making a build then it will be worked :slight_smile:

you can reset your game by using :
function OnCollisionEnter(collision : Collision) {

    //Will display if collision was detected
    print("Worked");

     //Reset the game
    Application.LoadLevel(0);// 0 is the index of first scene, you can see this by pressing ctrl+shift+b in editor
}

Application.Quit() will only work when you have built the game, I assume you are testing inside the unity editor at the moment.If the “Worked” is being printed its safe to assume everything is fine,for testing purpose I normally just reload the level.