Understanding the Matter.js collisionStart Event

In Matter.js, the collisionStart event fires at the beginning of a tick when two or more rigid bodies begin colliding. Listening to this event provides access to a comprehensive event payload that details the context of the physics engine at that moment, specifically delivering an array of colliding body pairs alongside geometric collision details, contact coordinates, and physical interaction properties.

Top-Level Event Object Properties

When an event callback is attached via Matter.Events.on(engine, 'collisionStart', callback), the callback receives an event object with the following primary properties:

The pairs Array and Pair Structure

Because multiple collisions can occur in a single physics update step, event.pairs groups all active collisions. Each element in the pairs array represents a distinct interaction between two bodies and contains the following key properties:

Geometric Collision Data (pair.collision)

Nested within each pair is the collision object, which provides low-level geometric and manifold data calculated by the Separating Axis Theorem (SAT) engine:

Contact Points and Dynamics Data

The pair object also includes details regarding the physical resolution parameters determined by combining properties of both bodies: