Skip to content

Search

Documentation

physics

What spans both physics worlds: pausing, sleeping, tuning and clearing. Bodies and colliders live in physics2d and physics3d.

On this page

What spans both physics worlds: pausing, sleeping, tuning and clearing. Bodies and colliders live in physics2d and physics3d.

12 functions, 0 constants. Scripts reach it as physics::.

Functions

Argument kinds are the script values a call passes: node is a node handle, any a table or value of any kind, fn a callback.

function acts on what it does
clear() — Remove every body and collider from both worlds, as a play-in-editor session does on stop.
counters() -> physics::Counters — What each world's last step spent its time on. The first call turns rapier's profilers on, so the numbers arrive from the step after it.
debug_draw() -> physics::DebugDraw — What the debug renderer is drawing now, every flag and nodes given.
is_paused() -> bool — Whether stepping is stopped.
quarantined() -> physics::Quarantined — What rapier disabled in each world's last step because a position, velocity or shape stopped being a number. Empty lists are the normal answer.
set_debug_draw(physics::DebugDraw) — Draw the physics world over the scene, as modes names it: DebugDraw { colliders: true } is the shapes, and enabled: false nothing. [physics.debug] holds the colours and lengths.
set_paused(bool) — Stop or resume stepping both worlds; nodes keep their poses.
set_sleeping_allowed(bool) — Allow or forbid resting bodies falling asleep, in both worlds and for bodies added later.
set_tuning(physics::TuningOptions) — Change how the solver behaves: solver_iterations, length_unit, ccd_substeps, contact softness, the soft_* rows and a soft_recovery record, the keys [physics] takes. A key at the top reaches both worlds; a physics3d or physics2d record holds keys for that world alone, which win over the top. Every value here changes results, so a recording only replays against the same numbers: prefer [physics], [physics.3d] and [physics.2d] in project.toml.
sleeping_allowed() -> bool — Whether resting bodies are allowed to fall asleep.
threads() -> int — How many threads the solver is using. One in a browser, unless the page is the threaded template and called initThreadPool.
tuning() -> physics::WorldTunings — The solver settings each world is running with, every key set_tuning takes, soft_recovery included.

Are you sure?