Matter.js Constraint Stiffness 1.0 vs 0.1 Explained

In Matter.js, the stiffness property dictates how rigidly a constraint maintains its resting length when subjected to external forces. This article breaks down the mechanical and visual differences between configuring a constraint with a stiffness value of 1.0 versus 0.1, explaining how the engine resolves positional offsets, how the bodies behave in real-time simulations, and when to use each setting.

How Constraint Stiffness Works in Matter.js

In Matter.js, constraints act as virtual springs or linkages between two bodies, or between one body and a fixed world coordinate. The stiffness property accepts a value ranging from 0 to 1 (though values greater than 1 can be used with multiple engine solver iterations). This value represents the fraction of positional error the solver corrects during each tick:


Behavior of Stiffness: 1.0 (Rigid Linkage)

When a constraint's stiffness is set to 1.0, it behaves like an inflexible, solid rod.


Behavior of Stiffness: 0.1 (Soft Spring)

When a constraint's stiffness is set to 0.1, it behaves like a loose, elastic spring or rubber band.


Direct Comparison

Feature Stiffness: 1.0 Stiffness: 0.1
Physical Analogy Solid steel rod Loose spring or rubber band
Positional Yield Nearly zero stretch Significant elongation under load
Oscillation None (instant equilibrium) High (springs back and forth)
Force Transfer Immediate and rigid Gradual and cushioned
Damping Requirement Rarely needed Often required to control endless bounce