Physics Basic Shape: OnPhysicsBasicShapeBlocked

An event that is invoked when the shape overlaps one or more other physics basic shapes.

This event will only be invoked if the set of overlapping objects has changed. That is, subsequent collisions with the same objects will not send more events.

Note that factors such as the speed of the object and the state of the simulation may mean that this event may fire shortly before or after the objects ‘overlap’.

Behavior Notes

Due to the nature of the physics simulation being run, if the basic shapes involved are too small or moving too fast, this event may be missed even though one shape passed through another.

The following table shows the maximum speed a 0.01 meter sized object can travel through objects of various thicknesses and still rely on this event occurring.

Size Of Larger Object (Meters) Maximum Reliable Speed (Metres Per Second)
0.05 1.25
0.1 2
0.25 2.5
0.5 10
0.75 15
1.0 25

So if an 0.01x0.01x0.01 cube was travelling through an 0.5x0.5x0.5 cube, the fastest it could travel and rely on this event occurring would be 10 meters per second.

The precise size, shape, and orientation of the shapes involved can affect this; the table above is a rough guide. Note that regardless of the objects involved, speeds above 25 meters per second are not supported with this event.

Event

void xxxxxxxxxxxxxxxxx(sender: object, collisions: object[]);

Parameters

Name Type Description
sender Object The physics basic shape that has collided with other shapes.
collisions Object[] One or more other physics basic shape that the sender is colliding with.

Example

function OnSimulationStart()
{
    let shape = GetComponentByNameAndType("PhysicsBasicShape1", "Physics Basic Shape");
    SubscribeToEvent("OnPhysicsBasicShapeBlocked", shape.Name, "Physics Basic Shape", ReportCollision);
    shape.GoToPosition(10, 0, 0, 1, 1, 1);
}

function ReportCollision(sender, collisions)
{
    LogDebug(`${sender.Name}: ${collisions.length} collisions:`);
    collisions.forEach(function (collision) {
        LogDebug(` - ${collision.Name}`);
    });
}