- Home /
Exit game when you crush into box collider?
Hi everyone! Could anyone give me a code sample on how to exit a game when you crash into a box collider? Tried to figure it out by my self, but with no luck, infortunatly.
Comment
Best Answer
Answer by syclamoth · Apr 29, 2012 at 02:22 PM
What's so hard about this?
void OnCollision(Collider other)
{
if(other == endBox)
{
Application.Quit();
}
}
Just assign 'endBox' in the inspector, a public Collider which you drag the box in question onto.
Your answer
![](https://koobas.hobune.stream/wayback/20220613070904im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Internal collisions 1 Answer
Adding a box collider to an object in csharp script 3 Answers
Tipping a cube over 2 Answers
Raycasting question 2 Answers
How to find all GameObjects within a specific field of view/box 2 Answers