‹›
Body State

Activation and Sleeping

Settled Dynamic bodies may sleep to avoid unnecessary simulation work. Sleeping is not destruction: the body remains in the world and can wake again. Disabling sleep for every body is usually unnecessary.

APIContract
body.activate() / deactivate()Requests wake/sleep; returns success status.
body.is_active()Reads activation, not handle validity.
body.set_allow_sleeping(enabled) / get_allow_sleeping()Controls whether the native body may sleep; unsupported motion properties can cause failure.
GML
if (!body.set_allow_sleeping(true)) show_debug_message(jolt_get_error_message());
if (!body.activate()) show_debug_message(jolt_get_error_message());

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.activateJoltBody.activate()Activate/sleep/allow sleeping: setters Boolean success, getters Boolean state (also false on error). Sleep does not destroy the body; disabling sleeping has a performance cost.
JoltBody.deactivateJoltBody.deactivate()Activate/sleep/allow sleeping: setters Boolean success, getters Boolean state (also false on error). Sleep does not destroy the body; disabling sleeping has a performance cost.
JoltBody.get_allow_sleepingJoltBody.get_allow_sleeping()Activate/sleep/allow sleeping: setters Boolean success, getters Boolean state (also false on error). Sleep does not destroy the body; disabling sleeping has a performance cost.
JoltBody.is_activeJoltBody.is_active()Activate/sleep/allow sleeping: setters Boolean success, getters Boolean state (also false on error). Sleep does not destroy the body; disabling sleeping has a performance cost.
JoltBody.set_allow_sleepingJoltBody.set_allow_sleeping(allow)Activate/sleep/allow sleeping: setters Boolean success, getters Boolean state (also false on error). Sleep does not destroy the body; disabling sleeping has a performance cost.