A Physics Constraint links two Physics objects together according to certain rules. Constraints can be used to attach objects to other objects, create ropes and chains, create rag doll animations, etc. Physics Constraint is a stand-alone component. Unlike Physics Shape, it does not need to be added to an existing Physics object. See the Physics reference for details on how physics simulation is structured in Story Machine.
All constraints require two objects to link together, as well as “pins” that define exactly where on those objects the link should occur. For example, when implementing a rag doll character, a Hinge constraint can be used to connect the arm to the body, with a pin position on each indicating the exact position of the joint.
Contact type
Indicates the type of constraint. Currently, the supported constraint types are:
- Distance - Links two objects together and forces them to maintain a fixed distance. Optionally allows that distance to squash and stretch like a spring.
- Hinge - Pins two objects together and allows them to rotate around the pin.
Body A
The first physics object to link with a constraint.
Pin Position
The position of the pin (in world coordinates relative to the pivot of the object) for this object.
Body B
The second object to link with this constraint.
Pin Position
The position of Body B’s pin.
Distance Constraint
Allow collisions
Whether to allow the two constrained objects to collide with each other.
Soft spring
If true, treat the constraint like a spring rather than a fixed pole.
Spring frequency
The frequency of the spring, in hertz. In most cases, it should be a value less than 30. For more information on spring frequencies, see Box2D’s documentation.
Damping
A value from 0 to 1 describing how much damping to apply to the spring over time. Damping causes spring movement to subside over time.
Min Length and Max Length
When using a spring, defines how far the spring can squash and stretch.
Hinge Constraint
Limit angle
If set, limits the hinge to rotation between a min and max angle.
Min angle
The minimum angle that the hinge is permitted to rotate to.
Max angle
The maximum angle that the hinge is permitted to rotate to.