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!
Please, next time format your code (I just did it for you this time). As for the question, make sure you are working with [colliders marked as triggers][1] and the [layers][2] are interacting with each other. [1]: http://docs.unity3d.com/Manual/CollidersOverview.html [2]: http://docs.unity3d.com/Manual/LayerBasedCollision.html
– Andres-FernandezDoes your character contain a Rigidbody?
– fafase