Constraints

Fixed Constraint

Locks the complete relative position and orientation of two bodies, or anchors one body rigidly to the world.

A Fixed constraint behaves like a weld. The body-to-body form preserves the complete relative transform that exists when it is created; the world form fixes one body around an explicit world-space anchor.

Syntax#

Syntax
jolt_fixed(body_a, body_b, options=undefined)
jolt_fixed_world(body, anchor_x, anchor_y, anchor_z, options=undefined)

Arguments#

ArgumentTypeDescription
body_a / body_bJoltBodyTwo different live managed bodies whose current relative transform will be locked.
bodyJoltBodyThe single live body used by jolt_fixed_world().
anchor_x / anchor_y / anchor_zRealWorld-space anchor used by the world variant.
optionsStruct or undefinedOptional initial collision and enabled settings.

Options#

FieldDefaultDescription
collisiontrueWhether body_a and body_b may collide. Ignored by the world variant.
enabledtrueWhether the new constraint participates in the solver immediately.

Methods#

MethodResultBehaviour
is_valid()BooleanChecks the managed wrapper and its native generational handle.
get_native_handle()RealReturns the opaque native handle, or 0 when invalid.
destroy()BooleanIdempotently releases only the constraint; connected bodies remain alive.
set_enabled(enabled) / get_enabled()BooleanTemporarily removes or restores solver participation without destroying the constraint.
set_collision_enabled(enabled) / get_collision_enabled()BooleanControls collision for a body pair. World variants always report false.

Example: welded compound mechanism#

GML
var carrier = jolt_box_create_dynamic(0, 0, 2, 2, 1, 0.5, { mass: 8 });
var payload = jolt_box_create_dynamic(0, 0, 3, 1, 1, 1, { mass: 2 });

var weld = jolt_fixed(carrier, payload, { collision: false });
if (is_undefined(weld)) {
    var error = jolt_get_error();
    show_debug_message(error.context + ": " + error.message);
}

The bodies retain their initial one-unit vertical separation and rotate as one rigid assembly. Their individual mass and inertia still contribute to the solver.

Example: fixed to world#

GML
var sign = jolt_box_create_dynamic(0, 0, 3, 2, 0.25, 1, { mass: 4 });
var mount = jolt_fixed_world(sign, 0, 0, 3);

Errors and lifecycle#

  • Body-to-body creators require two different live managed JoltBody values in the same managed default world.
  • At least one connected body must be movable; native Jolt rejects an unsupported static-static pair.
  • Constructors return a managed JoltConstraint on success or undefined after a validation/native creation failure.
  • Destroying either attached body automatically destroys and invalidates the constraint before releasing that body.
  • Read jolt_get_error() after a failed creator or method when the values may be untrusted.
  • jolt_fixed_world() requires a finite anchor and one live body in the managed default world.
  • A Fixed constraint has no limits, motor, spring, position or impulse getter in the managed API.
  • Use a narrower constraint when any relative degree of freedom should remain available.

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_fixedjolt_fixed(body_a, body_b, options = undefined)Returns JoltConstraint/undefined, does not own bodies. Two distinct live same-world bodies; _world variant one Dynamic body and fixed world. Enabled defaults true; ordinary two-body collision defaults true unless specified otherwise below. Also check jolt_has_error after creation: some subsequent options can fail while returning the created constraint. Fixed relative transform; world variant takes a world anchor m.
jolt_fixed_worldjolt_fixed_world(body, anchor_x, anchor_y, anchor_z, options = undefined)Returns JoltConstraint/undefined, does not own bodies. Two distinct live same-world bodies; _world variant one Dynamic body and fixed world. Enabled defaults true; ordinary two-body collision defaults true unless specified otherwise below. Also check jolt_has_error after creation: some subsequent options can fail while returning the created constraint. Fixed relative transform; world variant takes a world anchor m.