Constraints

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#

TypePermitted relative motionLimits / driveWorld variant
FixedNone; preserves complete relative transformNo limits or motorYes
PointAll rotation around one shared pointNo angular limits or motorYes
DistanceFree orientation within a length rangeMin/max distance and springYes
HingeOne rotational axisAngular limits, torque motor and springYes
SliderOne linear axisLinear limits, force motor and springYes
ConeCircular bounded swing plus free twistSingle swing half-angleYes
SwingTwistElliptical swing and bounded twistFriction plus separate swing/twist motorsNo
SixDOFAny axis may be fixed, free or limitedPer-axis friction, limits and motorsNo
PulleyTwo lengths coupled through a ratioTotal length rangeNo
PathTravel along a Hermite curvePath motor, friction and rotation modesSeparate Paths section

Public creators#

FactoryUsage
jolt_fixedSee the specific constraint reference for required arguments.
jolt_pointSee the specific constraint reference for required arguments.
jolt_distanceSee the specific constraint reference for required arguments.
jolt_hingeSee the specific constraint reference for required arguments.
jolt_sliderSee the specific constraint reference for required arguments.
jolt_coneSee the specific constraint reference for required arguments.
jolt_swing_twistSee the specific constraint reference for required arguments.
jolt_sixdofSee the specific constraint reference for required arguments.
jolt_pulleySee the specific constraint reference for required arguments.
jolt_pathSee 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#

MethodMeaning
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#

GML
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#

GML
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.