Constraints Overview
Selects and manages native Jolt solver relationships between bodies or between one body and the fixed world.
A constraint removes or controls relative degrees of freedom. Choose the narrowest type that describes the intended mechanism: simpler constraints are easier to configure, explain and tune than a fully general SixDOF joint.
Constraint selection#
| Type | Permitted relative motion | Limits / drive | World variant |
|---|---|---|---|
| Fixed | None; preserves complete relative transform | No limits or motor | Yes |
| Point | All rotation around one shared point | No angular limits or motor | Yes |
| Distance | Free orientation within a length range | Min/max distance and spring | Yes |
| Hinge | One rotational axis | Angular limits, torque motor and spring | Yes |
| Slider | One linear axis | Linear limits, force motor and spring | Yes |
| Cone | Circular bounded swing plus free twist | Single swing half-angle | Yes |
| SwingTwist | Elliptical swing and bounded twist | Friction plus separate swing/twist motors | No |
| SixDOF | Any axis may be fixed, free or limited | Per-axis friction, limits and motors | No |
| Pulley | Two lengths coupled through a ratio | Total length range | No |
| Path | Travel along a Hermite curve | Path motor, friction and rotation modes | Separate Paths section |
Public creators#
| Factory | Usage |
|---|---|
| jolt_fixed | See the specific constraint reference for required arguments. |
| jolt_point | See the specific constraint reference for required arguments. |
| jolt_distance | See the specific constraint reference for required arguments. |
| jolt_hinge | See the specific constraint reference for required arguments. |
| jolt_slider | See the specific constraint reference for required arguments. |
| jolt_cone | See the specific constraint reference for required arguments. |
| jolt_swing_twist | See the specific constraint reference for required arguments. |
| jolt_sixdof | See the specific constraint reference for required arguments. |
| jolt_pulley | See the specific constraint reference for required arguments. |
| jolt_path | See the specific constraint reference for required arguments. |
Common creation contract#
- Managed creators require jolt_start() and resources belonging to its active default world.
- Body-to-body creators require two different live JoltBody wrappers in that same world.
- Static-dynamic, kinematic-dynamic and dynamic-dynamic mechanisms are supported; unsupported static-static configurations fail natively.
- Creators return JoltConstraint on success or undefined on failure. Read jolt_get_error() for code, message and context.
- Public positions, anchors and ordinary axes are right-handed world-space X/Y/Z with Z up unless a page explicitly documents COM-local or constraint-space data.
Shared runtime interface#
| Method | Meaning |
|---|---|
| is_valid() | Checks the wrapper, managed world and native generational handle. |
| get_native_handle() | Returns an opaque handle for diagnostics/advanced interop, or 0 when invalid. |
| destroy() | Idempotently removes this constraint only. |
| set_enabled() / get_enabled() | Temporarily changes solver participation. |
| set_collision_enabled() / get_collision_enabled() | Controls collision for the connected user-body pair. |
Collision policy#
Classic body-to-body constraints default collision to true. SwingTwist and SixDOF default it to false. Disabling collision affects only that connected pair and is reference-counted when several constraints suppress the same pair. World variants have no second user body and always report false.
Update and cleanup order#
jolt_start();
// Create bodies and constraints.
// Step event:
jolt_update();
// Cleanup when needed:
joint.destroy();
body_a.destroy();
body_b.destroy();
jolt_stop();Debug drawing#
jolt_debug_enable(true);
jolt_debug_set(JOLT_DEBUG_CONSTRAINTS, true);
// Draw End, after opaque scene geometry:
jolt_debug_draw();The constraint debug layer visualizes live anchors, frames, limits, motors and type-specific solver geometry. It changes no simulation state.