Body Properties

Velocity

Reads or sets linear and angular body velocity.

Linear velocity uses world-space distance units per second. Angular velocity uses a world-space rotation vector in radians per second.

High-Level API#

GML
body.set_velocity(x, y, z)
body.get_velocity()
body.set_angular_velocity(x, y, z)
body.get_angular_velocity()

Return values#

MethodReturn
set_velocity / set_angular_velocityBoolean
get_velocity{x,y,z} or undefined
get_angular_velocity{x,y,z} or undefined

Restrictions and units#

  • All supplied components must be finite.
  • Setters reject Static bodies.
  • Dynamic and Kinematic bodies accept explicit velocity.
  • Linear velocity is world-space units/s; with the recommended scale it is m/s.
  • Angular velocity is radians/s, not degrees/s.
  • Setting velocity directly replaces the current value rather than adding to it.

Creation options#

GML
var body = jolt_sphere_create_dynamic(0, 0, 4, 0.5, {
    velocity: {x:3, y:0, z:2},
    angular_velocity: {x:0, y:2.5, z:0}
});

Kinematic movement#

move_kinematic() and move_kinematic_euler() calculate motion toward a target transform over a positive time interval. They are usually preferable to teleporting a Kinematic body because Dynamic contacts observe the resulting movement.

Low-Level / Advanced API#

Low-level component getters with _x, _y, and _z suffixes are also available.

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.get_angular_velocityJoltBody.get_angular_velocity()World XYZ vectors: linear m/s, angular rad/s. Setter Boolean; getter {x, y, z} or undefined on error.
JoltBody.get_velocityJoltBody.get_velocity()World XYZ vectors: linear m/s, angular rad/s. Setter Boolean; getter {x, y, z} or undefined on error.
JoltBody.set_angular_velocityJoltBody.set_angular_velocity(x, y, z)World XYZ vectors: linear m/s, angular rad/s. Setter Boolean; getter {x, y, z} or undefined on error.
JoltBody.set_velocityJoltBody.set_velocity(x, y, z)World XYZ vectors: linear m/s, angular rad/s. Setter Boolean; getter {x, y, z} or undefined on error.