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#
jolt_fixed(body_a, body_b, options=undefined)
jolt_fixed_world(body, anchor_x, anchor_y, anchor_z, options=undefined)Arguments#
| Argument | Type | Description |
|---|---|---|
| body_a / body_b | JoltBody | Two different live managed bodies whose current relative transform will be locked. |
| body | JoltBody | The single live body used by jolt_fixed_world(). |
| anchor_x / anchor_y / anchor_z | Real | World-space anchor used by the world variant. |
| options | Struct or undefined | Optional initial collision and enabled settings. |
Options#
| Field | Default | Description |
|---|---|---|
| collision | true | Whether body_a and body_b may collide. Ignored by the world variant. |
| enabled | true | Whether the new constraint participates in the solver immediately. |
Methods#
| Method | Result | Behaviour |
|---|---|---|
| is_valid() | Boolean | Checks the managed wrapper and its native generational handle. |
| get_native_handle() | Real | Returns the opaque native handle, or 0 when invalid. |
| destroy() | Boolean | Idempotently releases only the constraint; connected bodies remain alive. |
| set_enabled(enabled) / get_enabled() | Boolean | Temporarily removes or restores solver participation without destroying the constraint. |
| set_collision_enabled(enabled) / get_collision_enabled() | Boolean | Controls collision for a body pair. World variants always report false. |
Example: welded compound mechanism#
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#
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 / owner | Signature | Operation contract |
|---|---|---|
| jolt_fixed | jolt_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_world | jolt_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. |