Position
Reads or changes a JoltBody origin in world space.
Position uses the public right-handed Z-up coordinate system. It describes the body transform origin, which may differ from the centre of mass when center_of_mass_offset is used.
High-Level API#
body.get_position()
body.set_position(x, y, z)
body.get_transform()
body.get_center_of_mass_position()
body.get_center_of_mass_offset()Values and return types#
| Method | Returns | Description |
|---|---|---|
| get_position() | {x,y,z} or undefined | Current world-space body origin. |
| set_position(x,y,z) | Boolean | Teleports the origin to a finite world-space position. |
| get_transform() | Struct or undefined | Returns {position, rotation} from two validated reads. |
| get_center_of_mass_position() | {x,y,z} or undefined | Current world-space centre of mass. |
| get_center_of_mass_offset() | {x,y,z} | Creation-time local offset stored by the wrapper. |
Behaviour by motion type#
- Dynamic and Kinematic bodies are activated when set_position() succeeds.
- Static bodies can be repositioned but are not activated.
- set_position() is an immediate teleport; it does not calculate a velocity toward the target.
- Use move_kinematic() or move_kinematic_euler() when a Kinematic body must move to a target over time and interact with Dynamic bodies through the resulting velocity.
Kinematic target movement#
body.move_kinematic(x, y, z, qx, qy, qz, qw, seconds)
body.move_kinematic_euler(x, y, z, rx, ry, rz, seconds)These methods require a Kinematic body, finite target coordinates, a valid rotation, and finite seconds > 0. Euler angles are degrees. A successful call returns true.
Creation option and example#
var body = jolt_box_create_dynamic(0, 0, 4, 1, 1, 1, {
center_of_mass_offset: {x:0.25, y:0, z:-0.1}
});
body.set_position(3, -2, 6);
var origin = body.get_position();
var centre = body.get_center_of_mass_position();center_of_mass_offset must be a finite {x,y,z} struct and is immutable after creation.
Low-Level / Advanced API#
The low-level setter returns numeric 1/0. Component getters return Reals and use native error state for failure.
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 / owner | Signature | Operation contract |
|---|---|---|
| JoltBody.get_position | JoltBody.get_position() | 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_position | JoltBody.set_position(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. |