- Home /
Application.Quit() not working with collider
I have this bit of code that supposedly when two objects collide will exit/quit the game. Using the Debug.Log in the editor, I know the two objects are colliding with each other. But after building and trying, found out the Application.Quit() is not working.
void OnTriggerEnter()
{
Debug.Log("Hit quit button");
Application.Quit();
}
}
What did I do wrong? Does anyone know why it's not working? And can anyone tell me what's the best way to do it? Thank you so much.
Which platform are you getting build? I recommend you to read this documentation for details. http://docs.unity3d.com/Documentation/ScriptReference/Application.Quit.html
I am building it to PC standalone. The documentation doesn't really say quit being ignored in PC standalone.
Okay, "OnTriggerEnter()" method is take a collider parameter, it doesn't have an empty type.
OnTriggerEnter() works okay with my other objects. It works perfectly fine when I call Application.LoadlLevel ins$$anonymous$$d of the Application.Quit
void OnTriggerEnter() { Application.LoadLevel("AverageLevel");
}
Application.Quit() probably doesn't work in the player. Have you tried building your app and seeing if quit works?
http://docs.unity3d.com/Documentation/ScriptReference/Application.Quit.html
Answer by Maulik2208 · Nov 27, 2012 at 09:55 AM
Just keep it simple guys.....application.quit(); will never work on Gamescene......it will work after the build is transferred to the Device......i am using the same for ios and android devices and it's works fine so Don't penic.... just Relax and Enjoy
Answer by DeveshPandey · Nov 23, 2012 at 12:08 PM
Try this code:
void OnTriggerEnter()
{
Debug.Log("Hit quit button");
StartCoroutine("Quit");
}
}
IEnumrator Quit()
{
yield return true;
Application.Quit();
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613082205im_/https://answers.unity.com/themes/thub/images/avi.jpg)