This method is an alias for Factory.constraint
.
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.
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 |
---|---|---|---|---|
bodyA | MatterJS.BodyType |
The first possible |
||
bodyB | MatterJS.BodyType |
The second possible |
||
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.