Constraints

Cone Constraint

Keeps a shared anchor together and limits swing to a circular cone while leaving twist around the axis free.

Cone is useful for pendants, simple ball joints and links that may tilt by a maximum angle but do not need twist limits. For elliptical swing, twist limits or angular motors, use SwingTwist instead.

Syntax#

Syntax
jolt_cone(body_a, body_b, anchor_x, anchor_y, anchor_z, axis_x, axis_y, axis_z, max_angle, options=undefined)
jolt_cone_world(body, anchor_x, anchor_y, anchor_z, axis_x, axis_y, axis_z, max_angle, options=undefined)

Arguments and options#

NameDefaultDescription
body_a / body_brequiredConnected managed bodies.
bodyrequiredSingle body for the world variant.
anchor_x / anchor_y / anchor_zrequiredShared world-space pivot.
axis_x / axis_y / axis_zrequiredFinite non-zero reference direction, normalized internally.
max_anglerequiredSwing half-angle from 0 to 180 degrees.
collisiontrueBody-to-body collision state; ignored by the world variant.
enabledtrueInitial solver state.

Angular behaviour#

  • The current axis may swing away from the reference axis by at most max_angle.
  • Relative twist around that axis remains unconstrained.
  • A limit of 0 degrees locks swing; 180 degrees is effectively free swing.
  • The public API uses degrees and converts to Jolt radians internally.

Methods#

MethodResultCone behaviour
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.
set_limit(angle)BooleanSets the 0..180 degree swing half-angle.
get_limit()RealReturns the configured maximum swing in degrees.
get_angle()RealReturns the current swing angle in degrees.
get_impulse()RealReturns the latest positional/angular solver impulse summary.

Example: hanging lamp#

GML
var lamp = jolt_box_create_dynamic(0, 0, 3.5, 0.7, 0.7, 1, { mass: 3 });
var joint = jolt_cone_world(
    lamp,
    0, 0, 4,
    0, 0, -1,
    35
);

Body-to-body example#

GML
var joint = jolt_cone(upper, lower, 0, 0, 4.5, 0, 0, -1, 45, {
    collision: false
});
joint.set_limit(30);
var swing = joint.get_angle();

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.
  • Anchor and axis components must be finite, and the axis must have non-zero length.
  • max_angle and runtime limits must remain between 0 and 180 degrees.
  • Cone exposes no motor or spring. Use SwingTwist or SixDOF for powered angular control.

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_conejolt_cone(body_a, body_b, anchor_x, anchor_y, anchor_z, axis_x, axis_y, axis_z, max_angle, 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. World anchor/axis and max_angle degrees0..180.
jolt_cone_worldjolt_cone_world(body, anchor_x, anchor_y, anchor_z, axis_x, axis_y, axis_z, max_angle, 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. World anchor/axis and max_angle degrees0..180.
JoltConstraint.set_rotationJoltConstraint.set_rotation(angle)Hinge only: finite reference angle in degrees; Boolean. Changes the reference frame, does not teleport the body.