Description
The OnTriggerExit
property of the Collider
class is an event that is triggered when another collider exits the trigger area of this collider. This property is of type System.Action<Collider>
, meaning it can be assigned a delegate or lambda expression that takes a Collider
as a parameter.
Usage
To use the OnTriggerExit
property, you need to assign a method or lambda expression that matches the signature of System.Action<Collider>
. This method will be called whenever another collider exits the trigger area of this collider. Ensure that the IsTrigger
property of the collider is set to true
for the trigger events to work.
Example
// Example of using OnTriggerExit
Collider myCollider = new Collider();
// Ensure the collider is set as a trigger
myCollider.IsTrigger = true;
// Assign a method to the OnTriggerExit event
myCollider.OnTriggerExit = (exitingCollider) =>
{
// Handle the collider exit event
Log.Info($"Collider {exitingCollider} has exited the trigger area.");
};