Constraints (or joints) are used for specifying that a fixed distance must be maintained between two bodies, or a body and a fixed world-space position.
A world constraint has only one body, you should specify a pointA
position in
the constraint options parameter to attach the constraint to the world.
The stiffness of constraints can be modified to create springs or elastic.
To simulate a revolute constraint (or pin joint) set length: 0
and a high stiffness
value (e.g. 0.7
or above).
If the constraint is unstable, try lowering the stiffness
value and / or increasing
constraintIterations
within the Matter Config.
For compound bodies, constraints must be applied to the parent body and not one of its parts.
name | type | arguments | Default | description |
---|---|---|---|---|
body | MatterJS.BodyType |
The Matter |
||
length | number | <optional> |
A number that specifies the target resting length of the constraint. If not given it is calculated automatically in |
|
stiffness | number | <optional> | 1 |
A Number that specifies the stiffness of the constraint, i.e. the rate at which it returns to its resting |
options | Phaser.Types.Physics.Matter.MatterConstraintConfig | <optional> |
An optional Constraint configuration object that is used to set initial Constraint properties on creation. |
A Matter JS Constraint.