physics module
What spans both physics worlds: pausing, sleeping, tuning and clearing. Bodies and colliders live in physics2d and physics3d.
이 페이지의 내용
What spans both physics worlds: pausing, sleeping, tuning and clearing. Bodies and colliders live in physics2d and physics3d.
14 functions, 0 constants. Scripts reach it as physics::.
Acts on ragdoll: those functions are also methods on the component's handle, without the node argument.
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() -> any |
— | What each world's last step spent its time on, as #{ physics3d, physics2d }, each with every timer rapier keeps, in milliseconds (step_ms; the stages update_ms, user_changes_ms, collision_detection_ms, island_construction_ms, island_constraints_ms, solver_ms, ccd_ms; collision detection's broad_phase_ms, final_broad_phase_ms, narrow_phase_ms; the solver's velocity_resolution_ms, velocity_assembly_ms, velocity_assembly_bodies_ms, velocity_assembly_constraints_ms, velocity_update_ms, velocity_writeback_ms; continuous collision's ccd_time_of_impact_ms, ccd_solver_ms, ccd_broad_phase_ms, ccd_narrow_phase_ms) and every count (contact_pair_count, constraint_count, contact_count, ccd_substep_count). The first call turns rapier's profilers on, so the numbers arrive from the step after it. |
debug_draw() -> any |
— | What the debug renderer is drawing now, as a table of enabled, one flag per mode and nodes. |
is_paused() -> bool |
— | Whether stepping is stopped. |
quarantined() -> any |
— | What rapier disabled in each world's last step because a position, velocity or shape stopped being a number, as #{ physics3d, physics2d }, each #{ bodies, colliders, soft_bodies } lists of nodes. Empty lists are the normal answer. |
set_debug_draw(any) |
— | Draw the physics world over the scene: true for the usual shapes, or a table naming modes (#{ colliders = true, impulse_joints = true }): colliders, aabbs, axes, impulse_joints, multibody_joints, contacts, solver_contacts, soft_bodies, pseudo_normals, soft_volume_contacts, soft_stress (soft-body edges coloured by load), with nodes, a list of nodes whose bodies, colliders, joints, contacts and soft bodies alone are drawn. [physics.debug] holds the colours and lengths. |
set_paused(bool) |
— | Stop or resume stepping both worlds; nodes keep their poses. |
set_ragdoll_influence(node, float) |
ragdoll |
How much of the ragdoll's simulated pose the rig's bones take, 0 to 1: 0 leaves the clip in charge while the bodies simulate unseen, 1 goes limp. Tween it to fall over and get back up. |
set_sleeping_allowed(bool) |
— | Allow or forbid resting bodies falling asleep, in both worlds and for bodies added later. |
set_threads(int) -> any |
— | How many threads the solver may use, from a script's init: rayon's pool is built once, before the first step, and a call after that says so and changes nothing. [physics] threads in project.toml does the same and outranks nothing -- an init that asks wins. The default is one less than the machine reports, capped at eight. |
set_tuning(any) |
— | Change how the solver behaves: solver_iterations, length_unit, ccd_substeps, contact softness, the soft_* rows and a soft_recovery table, the keys [physics] takes. A key at the top reaches both worlds; a 3d or 2d table 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() -> any |
— | The solver settings each world is running with, as #{ "3d", "2d" }, each holding every key set_tuning takes, soft_recovery included. |