Constraints

SixDOF Constraint

Configures every relative translation and rotation axis as fixed, free or limited, with per-axis friction and motors.

SixDOF is the most flexible managed joint. Use it when Fixed, Hinge, Slider, Cone or SwingTwist cannot express the intended mechanism. Its power also makes correct frame, axis and unit documentation essential.

Syntax#

Syntax
jolt_sixdof(body_a, body_b, anchor_x, anchor_y, anchor_z, options=undefined)

Frame and general options#

FieldDefaultDescription
axis_x{x:1,y:0,z:0}Finite non-zero world-space frame X axis.
axis_y{x:0,y:1,z:0}Finite non-zero non-parallel world-space frame Y axis.
swing_typeJOLT_SIXDOF_SWING_CONECONE for elliptical symmetric swing or PYRAMID for asymmetric Y/Z swing.
collisionfalseWhether the connected bodies may collide.
enabledtrueInitial solver state.
frictionunsetArray of up to six non-negative per-axis force/torque limits.

Axis options#

FieldAxisAccepted value
linear_x / linear_y / linear_zTranslation X/Y/ZJOLT_SIXDOF_FIXED, JOLT_SIXDOF_FREE, 'fixed', 'locked', 'free', or {min,max} in world units.
angular_xRotation X / twistFixed, free, or {min,max} in degrees within -180..180.
angular_y / angular_zCoupled swingFixed, free, or {min,max} in degrees within -180..180.

Constants#

ConstantsValues / meaning
JOLT_SIXDOF_TRANSLATION_X / Y / Z0 / 1 / 2
JOLT_SIXDOF_ROTATION_X / Y / Z3 / 4 / 5
JOLT_SIXDOF_FIXED / FREE / LIMITED0 / 1 / 2
JOLT_SIXDOF_SWING_CONE / PYRAMIDSymmetric elliptical swing / asymmetric pyramidal swing

Axis methods#

Method groupMethods
Modeset_axis_free(), set_axis_fixed(), set_axis_limit(), get_axis_mode(), is_axis_free(), is_axis_fixed()
Limitsget_axis_min(), get_axis_max(), get_axis_limit()
Translation shortcutsset_translation_limits(), get_translation_limits_min(), get_translation_limits_max()
Rotation shortcutsset_rotation_limits(), get_rotation_limits_min(), get_rotation_limits_max()
Frictionset_friction(axis,value), get_friction(axis)

Rotation semantics#

  • Rotation X is Jolt twist. Rotation Y and Z are coupled swing dimensions, not independent Euler clamps.
  • CONE swing requires limited Y/Z ranges symmetric around zero and creates an elliptical cone.
  • PYRAMID permits asymmetric Y/Z ranges.
  • Linear values use world units; high-level angular limits and angular velocities use degrees.

Motor methods#

MethodPurpose
set_axis_motor_state(axis,state) / get_axis_motor_state(axis)Selects Off, Velocity, Position or PositionAndVelocity for one axis.
set_target_position(x,y,z) / get_target_position()Translation position target in body-1 constraint space.
set_target_velocity(x,y,z) / get_target_velocity()Translation velocity target in body-1 constraint space.
set_target_angular_velocity(x,y,z) / get_target_angular_velocity()Angular velocity target in degrees/s, using body-2 constraint space in Jolt 5.6.
set_target_orientation(x,y,z,w)Authoritative normalized quaternion orientation target.
set_target_orientation_euler(x,y,z)Degree-based convenience conversion to a target quaternion.
get_target_orientation() / get_current_orientation()Target and current constraint-space quaternions.
get_target_orientation_euler() / get_current_orientation_euler()Convenience Euler representations.
set_axis_motor_limit(axis,value) / get_axis_motor_limit(axis)Force limit for translation or torque limit for rotation.
set_axis_motor_spring(axis,frequency,damping)Per-axis native position-motor spring.
get_axis_motor_spring(axis)Returns {frequency,damping} for the selected SixDOF axis. Use a live SixDOF constraint and a JOLT_SIXDOF_* axis; inspect native errors immediately if readback fails.

Soft limits and solver state#

MethodResult
set_limit_spring(axis, frequency, damping)Softens Translation X/Y/Z limits only.
get_limit_spring(axis)Returns {frequency,damping}.
get_impulses()Returns translation, rotation, motor_translation and motor_rotation vectors.
get_sixdof_debug_frame()Returns the live constraint frame used by diagnostics.

Example: slider-like Z motion#

GML
var joint = jolt_sixdof(body_a, body_b, 0, 0, 2, {
    linear_z: { min:0, max:3 },
    collision: false
});

Example: driven translation axis#

GML
joint.set_axis_free(JOLT_SIXDOF_TRANSLATION_X);
joint.set_axis_motor_limit(JOLT_SIXDOF_TRANSLATION_X, 120);
joint.set_axis_motor_spring(JOLT_SIXDOF_TRANSLATION_X, 3, 0.8);
joint.set_target_position(2, 0, 0);
joint.set_axis_motor_state(JOLT_SIXDOF_TRANSLATION_X, JOLT_MOTOR_POSITION);

Validation and lifecycle#

  • The creator requires two different live bodies, a finite anchor and two finite, non-zero, non-parallel frame axes.
  • Every limited axis needs finite ordered min/max values; angular values must remain within -180..180 degrees.
  • Per-axis friction is force for translations and torque for rotations.
  • Runtime mutations wake connected bodies; getters do not.
  • Destroying either body invalidates the constraint. destroy() and jolt_stop() are safe and ordered.
  • There is currently no jolt_sixdof_world() convenience creator.

Verified operation contracts#

These contracts distinguish units, return values, errors and lifetime according to the current implementation. Check results: false, 0 and undefined can mean different things for different methods.

Symbol / ownerSignatureOperation contract
jolt_sixdofjolt_sixdof(body_a,body_b,anchor_x,anchor_y,anchor_z,options=undefined)Two bodies, world anchor, axis_x/y default+X/+Y. All6 axes default FIXED; linear_x/y/z m, angular_x/y/z°:FIXED/FREE or {min, max}. Default CONE requires swing Y/Z symmetry, PYRAMID allows asymmetry. Collisionfalse, enabledtrue; Constraint/undefined.
JoltConstraint.get_axis_limitJoltConstraint.get_axis_limit(axis)SixDOF axis 0..5; min/max in m for translation, ° for rotation. get_axis_limit returns {mode, minimum, maximum}. Error fallbacks are FIXED/0/0; check validity and error state.
JoltConstraint.get_axis_maxJoltConstraint.get_axis_max(axis)SixDOF axis 0..5; min/max in m for translation, ° for rotation. get_axis_limit returns {mode, minimum, maximum}. Error fallbacks are FIXED/0/0; check validity and error state.
JoltConstraint.get_axis_minJoltConstraint.get_axis_min(axis)SixDOF axis 0..5; min/max in m for translation, ° for rotation. get_axis_limit returns {mode, minimum, maximum}. Error fallbacks are FIXED/0/0; check validity and error state.
JoltConstraint.get_axis_modeJoltConstraint.get_axis_mode(axis)SixDOF axis 0..5. FREE/FIXED/LIMITED mode or Boolean comparison; on error get_axis_mode returns FIXED, so is_axis_fixed can be true on error.
JoltConstraint.get_axis_motor_limitJoltConstraint.get_axis_motor_limit(axis)SixDOF axis 0..5; N for translation, N·m for rotation; 0 for invalid wrapper/type, inspect native errors separately.
JoltConstraint.get_axis_motor_springJoltConstraint.get_axis_motor_spring(axis)SixDOF: {frequency, damping}, Hz and ratio. Motor axes 0..5, limit only 0..2; on error components may contain native fallback 0.
JoltConstraint.get_axis_motor_stateJoltConstraint.get_axis_motor_state(axis)SixDOF axis 0..5, JOLT_MOTOR_* state. Setter Boolean; getter numeric mode or OFF for invalid wrapper/type.
JoltConstraint.is_axis_fixedJoltConstraint.is_axis_fixed(axis)SixDOF axis 0..5. FREE/FIXED/LIMITED mode or Boolean comparison; on error get_axis_mode returns FIXED, so is_axis_fixed can be true on error.
JoltConstraint.is_axis_freeJoltConstraint.is_axis_free(axis)SixDOF axis 0..5. FREE/FIXED/LIMITED mode or Boolean comparison; on error get_axis_mode returns FIXED, so is_axis_fixed can be true on error.
JoltConstraint.set_axis_fixedJoltConstraint.set_axis_fixed(axis)SixDOF only, integer axis 0..5 (translation X/Y/Z, rotation X/Y/Z). Boolean; fixed locks at 0, free removes the limit.
JoltConstraint.set_axis_freeJoltConstraint.set_axis_free(axis)SixDOF only, integer axis 0..5 (translation X/Y/Z, rotation X/Y/Z). Boolean; fixed locks at 0, free removes the limit.
JoltConstraint.set_axis_limitJoltConstraint.set_axis_limit(axis,minimum,maximum)SixDOF, integer axis 0..5; finite min≤max. Translation in m, rotation within -180..180°. Cone swing type requires symmetric Y/Z rotation limits around 0. Boolean.
JoltConstraint.set_axis_motor_limitJoltConstraint.set_axis_motor_limit(axis,value)SixDOF axis 0..5; finite nonnegative force limit (axes 0..2, N) or torque limit (3..5, N·m). Boolean. Setting a limit alone does not enable a motor.
JoltConstraint.set_axis_motor_springJoltConstraint.set_axis_motor_spring(axis,frequency,damping)SixDOF axis 0..5; finite frequency ≥0 Hz and damping ≥0 as damping ratio. Boolean.
JoltConstraint.set_axis_motor_stateJoltConstraint.set_axis_motor_state(axis,state)SixDOF axis 0..5, JOLT_MOTOR_* state. Setter Boolean; getter numeric mode or OFF for invalid wrapper/type.