Body Properties

Rotation

Reads and changes body orientation using quaternions or Euler-degree helpers.

The canonical native representation is a normalized quaternion {x,y,z,w}. High-level helpers also accept Euler angles in degrees around public X, then Y, then Z.

High-Level API#

GML
body.get_rotation()
body.get_rotation_euler()
body.set_rotation(x, y, z)
body.set_rotation(x, y, z, w)
body.set_rotation_euler(x_degrees, y_degrees, z_degrees)

Overload rules#

CallMeaningReturn
set_rotation(x,y,z)Euler degreesBoolean
set_rotation(x,y,z,w)QuaternionBoolean
get_rotation()Normalized quaternion {x,y,z,w}Struct or undefined
get_rotation_euler()Converted Euler degrees {x,y,z}Struct or undefined

Euler composition#

jolt_quaternion_from_euler() composes q = qZ * qY * qX, so rotations are applied around public X, then Y, then Z. Euler representations are not unique and may become unstable near gimbal-lock orientations; retain quaternions when round-trip fidelity matters.

Creation options#

GML
var body = jolt_box_create_dynamic(0, 0, 3, 2, 1, 1, {
    rotation: {x:0, y:0, z:0, w:1}
});

var tilted = jolt_box_create_dynamic(3, 0, 3, 2, 1, 1, {
    rotation_euler: {x:15, y:30, z:90}
});

If both rotation and rotation_euler are present, quaternion rotation is applied first and rotation_euler replaces it afterwards. Supply only one to avoid ambiguity.

Motion behaviour#

  • Changing rotation is an immediate transform update, not angular motion.
  • Dynamic and Kinematic bodies are activated; Static bodies are updated without activation.
  • Use move_kinematic or move_kinematic_euler for time-based Kinematic movement.
  • Use angular velocity, torque, or angular impulse for simulated rotation.

Low-Level / Advanced API#

Setters return true on success and false on invalid input, an invalid or stale body, or an unsupported motion type. Getters return the requested value or undefined when the operation fails. Inspect jolt_get_error() for the high-level error.

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
JoltBody.clear_grab_rotationJoltBody.clear_grab_rotation()Local grab frame +Y forward/+Z up. Setter accepts a quaternion struct or four components, three means Euler°. Clear restores identity; setters Boolean, getter XYZW or undefined when invalid.
JoltBody.get_grab_rotationJoltBody.get_grab_rotation()Local grab frame +Y forward/+Z up. Setter accepts a quaternion struct or four components, three means Euler°. Clear restores identity; setters Boolean, getter XYZW or undefined when invalid.
JoltBody.get_rotationJoltBody.get_rotation()World {x, y, z} m / XYZW quaternion / Euler XYZ° / {position, rotation}, according to method. undefined on error. Position is body origin, not COM.
JoltBody.get_rotation_eulerJoltBody.get_rotation_euler()World {x, y, z} m / XYZW quaternion / Euler XYZ° / {position, rotation}, according to method. undefined on error. Position is body origin, not COM.
JoltBody.set_grab_rotationJoltBody.set_grab_rotation(x,y=undefined,z=undefined,w=undefined)Local grab frame +Y forward/+Z up. Setter accepts a quaternion struct or four components, three means Euler°. Clear restores identity; setters Boolean, getter XYZW or undefined when invalid.
JoltBody.set_grab_rotation_eulerJoltBody.set_grab_rotation_euler(x,y,z)Local grab frame +Y forward/+Z up. Setter accepts a quaternion struct or four components, three means Euler°. Clear restores identity; setters Boolean, getter XYZW or undefined when invalid.
JoltBody.set_rotationJoltBody.set_rotation(x, y, z, w = undefined)Boolean teleport; world position m, XYZW rotation or Euler XYZ°. set_rotation with three components means Euler°, four means quaternion. Synchronizes attached sensors; use move_kinematic for a moving platform.
JoltBody.set_rotation_eulerJoltBody.set_rotation_euler(x, y, z)Boolean teleport; world position m, XYZW rotation or Euler XYZ°. set_rotation with three components means Euler°, four means quaternion. Synchronizes attached sensors; use move_kinematic for a moving platform.