OnTriggerExit(Collider)
OnTriggerExit is called when a collider stops touching a trigger.
Read time 1 minuteLast updated 4 days ago
Definition
- Type: Method
- Namespace: UnityEngine
OnTriggerExit()
public void OnTriggerExit(Collider other)
Parameters
The other collider involved in this collision.
Remarks
OnTriggerExitFixedUpdateBoth GameObjects must contain a Collider component. At least one of the colliders must be a trigger collider and at least one must be a physics body collider. For more information, refer to OnTrigger events.
Trigger events are sent to disabled MonoBehaviours, to allow enabling Behaviours in response to collisions. Deactivating or destroying a collider while it is inside a trigger volume does not cause an message to be sent.
OnTriggerExitBoth the trigger and the collider that touches the trigger receive if they have implemented it.
OnTriggerEnterOnTriggerExitExamples
// Destroy everything that leaves the triggerusing UnityEngine;using System.Collections;public class ExampleClass : MonoBehaviour{ void OnTriggerExit(Collider other) { Destroy(other.gameObject); }}