Body Properties

Impulses

Applies an instantaneous linear or angular momentum change to a Dynamic body.

Use impulses for hits, jumps, explosions, recoil, and one-frame interactions. Unlike a force, an impulse is applied once and is not multiplied by the simulation duration.

High-Level API#

GML
body.add_impulse(x, y, z)
body.add_impulse_at_position(ix, iy, iz, px, py, pz)
body.add_impulse_local(ix, iy, iz, local_x, local_y, local_z)
body.add_angular_impulse(x, y, z)

Coordinate spaces#

MethodImpulse spaceApplication point
add_impulseWorld-spaceCentre of mass
add_impulse_at_positionWorld-spaceWorld-space point
add_impulse_localWorld-spaceLocal point transformed by body rotation and origin
add_angular_impulseWorld-space angular impulseDirect rotation

The local helper transforms only the point; the impulse vector remains world-space. An off-centre impulse changes both linear and angular velocity. All components must be finite.

Impulse vs. force#

PropertyForceImpulse
ApplicationUsually every stepOnce
Time dependenceIntegrated over timestepImmediate momentum change
Typical unit at recommended scaleNN·s or kg·m/s
Typical useThruster, attraction, dragHit, jump, recoil

Example#

GML
// One immediate launch.
body.add_impulse(0, 0, 12);

// Add spin by hitting away from the centre.
body.add_impulse_local(8, 0, 3, 0, -0.6, -0.4);

// Direct angular momentum.
body.add_angular_impulse(0, 0, 2.5);

Low-Level / Advanced API#

Low-level at_position uses a world-space point. add_impulse_local is implemented by the high-level wrapper.

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.add_angular_impulseJoltBody.add_angular_impulse(x, y, z)Boolean; Dynamic body, world torque N·m / angular impulse N·m·s. Torque is per-step, impulse one-shot.
JoltBody.add_impulseJoltBody.add_impulse(x, y, z)Boolean; Dynamic body, one-shot world XYZ impulse in N·s. at_position world point, local only the point relative to origin; impulse vector stays world-space.
JoltBody.add_impulse_at_positionJoltBody.add_impulse_at_position(ix, iy, iz, px, py, pz)Boolean; Dynamic body, one-shot world XYZ impulse in N·s. at_position world point, local only the point relative to origin; impulse vector stays world-space.