Engine API Reference - v2.7.3
    Preparing search index...

    Class ContactPoint

    Represents a single point of contact between two colliding rigid bodies in the physics simulation. Each contact point stores detailed spatial information about the collision, including both local and world space coordinates of the exact contact points on both entities, the contact normal direction, and the collision impulse force.

    Contact points are generated by the physics engine during collision detection and are typically accessed through a ContactResult object, which can contain multiple contact points for a single collision between two entities. Multiple contact points commonly occur when objects collide along edges or faces rather than at a single point.

    The impulse property can be particularly useful for gameplay mechanics that need to respond differently based on the force of impact, such as damage calculations or sound effect volume.

    // Access contact points from a collision event
    entity.collision.on('contact', (result) => {
    // Get the first contact point
    const contact = result.contacts[0];

    // Get the contact position in world space
    const worldPos = contact.point;

    // Check how hard the collision was
    if (contact.impulse > 10) {
    console.log("That was a hard impact!");
    }
    });
    Index

    Properties

    impulse: number

    The total accumulated impulse applied by the constraint solver during the last sub-step. This value represents how hard two objects collided. Higher values indicate stronger impacts.

    localPoint: Vec3

    The point on the entity where the contact occurred, relative to the entity.

    localPointOther: Vec3

    The point on the other entity where the contact occurred, relative to the other entity.

    normal: Vec3

    The normal vector of the contact on the other entity, in world space. This vector points away from the surface of the other entity at the point of contact.

    point: Vec3

    The point on the entity where the contact occurred, in world space.

    pointOther: Vec3

    The point on the other entity where the contact occurred, in world space.