Matter.js Body Friction Property Explained

In Matter.js, the friction property dictates the kinetic (sliding) resistance of a rigid body when it moves against another body's surface. This article explains how the friction property operates, how its values influence motion, how friction is calculated during collisions between two surfaces, and how it contrasts with static and air friction properties in the physics engine.

Kinetic Friction Mechanics

The friction property represents dynamic or sliding friction. When an object is in direct contact with another body and moving across it, kinetic friction exerts an opposing force parallel to the contact surface, causing the object to decelerate and eventually come to a stop.

Values and Defaults

How Matter.js Resolves Collision Friction

Friction is never calculated in isolation. When two bodies touch, Matter.js calculates an effective friction for the interaction. By default, the engine determines the combined friction using the minimum value of the two colliding bodies:

\[\text{Effective Friction} = \min(\text{bodyA.friction}, \text{bodyB.friction})\]

Because of this calculation, if one body has a friction value of 0, the contact pair will behave frictionlessly, regardless of how high the friction value is on the second body.

Comparison With Other Friction Properties

Matter.js provides three distinct friction settings on a body: