Description
The OnIntersectionStart
property of the PhysicsBody
class is an event handler that is triggered when a physics intersection begins. This property is of type System.Action<PhysicsIntersection>
, which means it can be assigned a delegate or lambda expression that takes a PhysicsIntersection
object as a parameter. This event is useful for detecting when two physics bodies start intersecting, allowing you to execute custom logic in response to this event.
Usage
To use the OnIntersectionStart
property, you need to assign a method or lambda expression that matches the signature of System.Action<PhysicsIntersection>
. This method will be called whenever an intersection starts involving the PhysicsBody
instance.
Ensure that the PhysicsBody
is properly configured to detect intersections, and that the necessary physics simulation settings are enabled.
Example
// Example of setting up an OnIntersectionStart event handler
PhysicsBody myPhysicsBody = new PhysicsBody();
// Assign a lambda expression to handle the intersection start event
myPhysicsBody.OnIntersectionStart = (intersection) =>
{
// Custom logic to execute when an intersection starts
Log.Info($"Intersection started with: {intersection.OtherBody}");
};