Description
The OnObjectTriggerExit
property is an event handler that is invoked when a GameObject
exits the trigger area of a Collider
component. This property is particularly useful for detecting when objects leave a specific area or volume defined by the collider, allowing developers to implement custom logic in response to such events.
Usage
To use the OnObjectTriggerExit
property, assign a method that matches the Action<GameObject>
delegate signature. This method will be called whenever a GameObject
exits the trigger collider.
Ensure that the IsTrigger
property of the Collider
is set to true
to enable trigger functionality.
Example
// Example of using OnObjectTriggerExit
Collider myCollider = new Collider();
// Ensure the collider is set as a trigger
myCollider.IsTrigger = true;
// Assign a method to the OnObjectTriggerExit event
myCollider.OnObjectTriggerExit = (GameObject obj) =>
{
// Custom logic when a GameObject exits the trigger
Log.Info($"GameObject {obj.Name} has exited the trigger.");
};