Body State

Center of Mass

The public body origin is used for placement and binding. The centre of mass is the physical point used by dynamics and can differ from that origin. Off-centre forces produce torque around the centre of mass.

APIContract
options.center_of_mass_offsetCreation-time local {x,y,z} offset; no runtime setter is provided.
body.get_center_of_mass_offset()Reads the local offset.
body.get_center_of_mass_position()Reads the current world-space centre of mass.
GML
var body = jolt_box_create_dynamic(0, 0, 3, 1, 1, 2, {
    center_of_mass_offset: {x: 0, y: 0, z: -0.25}
});
if (!is_undefined(body)) show_debug_message(body.get_center_of_mass_position());
jolt_debug_enable(true);
jolt_debug_set(JOLT_DEBUG_CENTER_OF_MASS, true);

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_center_of_mass_offsetJoltBody.get_center_of_mass_offset()Local XYZ offset in m; setter Boolean, getter copies wrapper-stored {x, y, z}. Moving COM does not move the render origin.
JoltBody.get_center_of_mass_positionJoltBody.get_center_of_mass_position()Current world COM {x, y, z} in m, undefined on error.
JoltBody.set_center_of_mass_offsetJoltBody.set_center_of_mass_offset(x,y,z)Local XYZ offset in m; setter Boolean, getter copies wrapper-stored {x, y, z}. Moving COM does not move the render origin.