Description
The OnTriggerEnter
property of the HammerMesh
class is an event handler that is invoked when a collider enters the trigger associated with this HammerMesh
component. This property is of type System.Action<Collider>
, allowing you to define a custom action to be executed when the trigger event occurs.
Usage
To use the OnTriggerEnter
property, assign a method that matches the Action<Collider>
delegate signature. This method will be called whenever a collider enters the trigger area of the HammerMesh
component.
Ensure that the IsTrigger
property of the HammerMesh
is set to true
to enable trigger functionality.
Example
// Example of setting up the OnTriggerEnter event handler
HammerMesh hammerMesh = new HammerMesh();
// Define the action to be taken when a collider enters the trigger
hammerMesh.OnTriggerEnter = (collider) =>
{
// Custom logic when a collider enters the trigger
Log.Info($"Collider {collider.Name} has entered the trigger.");
};
// Ensure the IsTrigger property is set to true
hammerMesh.IsTrigger = true;