- Home /
Help with a killbox
Hello! I'm having an issue with my killbox. Any script that I try applying to the plane below the scene doesn't work. Any suggestions on code?
Answer by Bunny83 · Mar 13, 2013 at 05:10 PM
Don't use a plane, use a box collider and don't make it too small in height, otherwise if you fall fast you could "teleport" through it.
The code depends on your game mechanics. If you want the player or other things to get destroyed or "respawned" / teleported. However in general the boxcollider should be a trigger (isTrigger checked) and use:
// UnityScript
function OnTriggerEnter(aOther : Collider)
{
Destroy(aOther.gameObject);
}
If your player has quite deep nested colliders it's better to use:
Destroy(aOther.transform.root.gameObject);
This will go up the hierarchy and destroy the top most object.
How would I go about teleporting a player back to spawn when they hit the box with C#?
Your answer
![](https://koobas.hobune.stream/wayback/20220613094335im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Quad mesh collider detects side collisions when it should not 0 Answers
2D rouguelike, ending the game. 0 Answers
Find all objects currently colliding with trigger 1 Answer
End Game Collider 1 Answer
Help with a collision problem. 2 Answers