OnTriggerExit

Hi!

I have been trying to make a script so that if the character (cube with a box collider) you control exits a capsule collider (cylinder) it destroys the game object of that character. Its going to be like a arena, if the character exits he falls off the arena and dies (the gameobject is destroyed).

I have this script attached on the arena (with the capsule collider).

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    void OnTriggerExit(Collider other) {
        Destroy(other.gameObject);
    }
}

But when the character (cube) exits the collider nothing happens with it.

Please help me, the scripts really seems fine to me.

Cheers!

For this to work you need:
1.The gameobject with the script to have a Rigidbody component
2.You need to make sure that the trigger object have isTrigger checked.

And if you want only specific object to be deleted(like your player) you can do:
1.Tag your player with ‘Player’ tag
and then this script will work only if your player is exiting the arena

using UnityEngine;
 using System.Collections;
 
 public class ExampleClass : MonoBehaviour {
     void OnTriggerExit(Collider other) {
         if(other.gameObject.tag == "Player")
         Destroy(other.gameObject);
     }
 }