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!
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