Constraints
World Constraints
Attaches one managed body directly to Jolt's immutable fixed world body without creating a static helper body.
World variants use the same JoltConstraint runtime methods as their body-to-body counterparts, but accept one user body and keep their world anchor/frame fixed forever.
Available creators#
| Function | Purpose |
|---|---|
| jolt_fixed_world(body, anchor_x, anchor_y, anchor_z, options) | Rigidly fixes one body to the world. |
| jolt_point_world(body, anchor_x, anchor_y, anchor_z, options) | Creates a freely rotating world pivot. |
| jolt_distance_world(body, anchor_x, anchor_y, anchor_z, min, max, options) | Keeps a body within a distance range of a fixed point. |
| jolt_hinge_world(body, anchor_x, anchor_y, anchor_z, axis_x, axis_y, axis_z, options) | Creates a world-space rotational hinge. |
| jolt_slider_world(body, anchor_x, anchor_y, anchor_z, axis_x, axis_y, axis_z, options) | Creates a world-space linear rail. |
| jolt_cone_world(body, anchor_x, anchor_y, anchor_z, axis_x, axis_y, axis_z, max_angle, options) | Creates a circular swing joint against the world. |
Shared rules#
- The body must be a live managed JoltBody in the active default world.
- Anchor and axis inputs are finite world-space values; axes must be non-zero.
- The collision option has no effect because Jolt's fixed world body is not a user collision body.
- set_collision_enabled() succeeds as a no-op and get_collision_enabled() always returns false.
- enabled and all type-specific limits, motors, springs and getters behave like the matching body-to-body type.
- There are no SwingTwist, SixDOF or Pulley world convenience creators in the current managed API.
Examples#
var door = jolt_hinge_world(panel, 0, 0, 2, 0, 0, 1, {
limits_min: 0,
limits_max: 100
});
var rail = jolt_slider_world(drawer, 0, 0, 1, 0, 1, 0, {
limits_min: -0.5,
limits_max: 0.5
});
var tether = jolt_distance_world(load, 0, 0, 6, 2, 4, {
spring_frequency: 2,
spring_damping: 0.7
});Lifecycle#
Destroying the user body invalidates its world constraints. Destroying a constraint does not destroy the body. jolt_stop() removes all constraints before bodies and the default world.