body_2d
2D physics: a box (or a convex shape) that collides with tiles, slopes and other bodies. kind "player" runs and jumps from the controls (coyote time, jump buffering, variable jump height), "topdown" walks 8 ways from the controls with no gravity (pushes crates, picks up carry bodies with E), "projectile" flies at its velocity and reports "hit" on the first thing it meets (swept: never passes through), "actor" has gravity and is moved by its script (self.velocity), "dynamic" bounces and gets pushed, "solid" stands still or travels (moving platforms, blocks), "sensor" only reports overlaps (onEnter/onExit: coins, flags). Bumping a solid from below sends it "bumped".
In scene text
body_2d { kind "…" size (0, 1, 0) offset (0, 1, 0) }Add it in the Inspector (Add Component), in scene text as above, or ask your AI. Fields you leave out keep their defaults.
Fields 38
| Field | Type | Unit / range | What it does |
|---|---|---|---|
kind | text | — | "player", "topdown", "actor", "dynamic", "projectile", "solid" or "sensor". |
size | (x, y, z) | units | The box (width, height); its bottom middle sits on the position. |
offset | (x, y, z) | units | Moves the box from the position. |
solid | true / false | — | Others stand on it and are stopped by it (always for "solid"). |
one_way | true / false | — | Solid only from above: stand on it, jump up through it. |
gravity_scale | number | 0 … 10 | Gravity multiplier (0 floats). |
run_speed | number | units/s, 0 … 100000 | Player: top running speed. |
sprint_speed | number | units/s, 0 … 100000 | Player: top speed with the run button (Shift). |
acceleration | number | units/s², 0 … 1e+06 | Player: how fast it gets to speed. |
deceleration | number | units/s², 0 … 1e+06 | Player: how fast it stops when let go. |
air_control | number | 0 … 1 | Player: share of acceleration in the air. |
jump_height | number | units, 0 … 100000 | Player: a full jump's height; gravity follows from it and jump_time. |
jump_time | number | s, 0.05 … 5 | Player: seconds to the top of a full jump. |
fall_gravity | number | 0.1 … 10 | Gravity multiplier while falling (snappy landings). |
jump_cut_gravity | number | 1 … 20 | Gravity multiplier while rising after jump is let go (tap: short hop). |
max_fall | number | units/s, 0 … 100000 | Fastest fall. |
coyote_time | number | s, 0 … 1 | Player: a jump still works this long after running off a ledge. |
jump_buffer | number | s, 0 … 1 | Player: a press this long before landing still jumps. |
climb_speed | number | units/s, 0 … 100000 | Player: speed on ladder tiles. |
bounce | number | 0 … 1 | Dynamic: bounciness. |
friction | number | 0 … 100 | Dynamic: how fast it stops sliding on the ground. |
travel | (x, y, z) | units | Moving solid: its trip from the start (x, y); riders move with it. |
period | number | s, 0 … 10000 | Moving solid: seconds there and back (0: it stays). |
animate | true / false | — | Plays the sprite's clips from its movement: idle, run, jump, fall, climb (top-down: walk_up, walk_down, walk_side, idle_up...). |
shape | list of text | — | Solid bodies: a convex outline instead of the box, points "x,y" in units from the position (["-40,0", "40,0", "0,60"]): rocks, ramps, slanted walls. Turns with rotation z. |
max_slope | number | deg, 0 … 89 | Platform movers: the steepest slope they walk up (steeper is a wall). |
carry | true / false | — | Top-down: can be picked up with the use key (E), carried overhead, put down or thrown (self.throw). |
mass | number | 0.01 … 1000 | Water impact mass. |
density | number | 0.05 … 10 | Density relative to water; 0.55 floats 55 percent submerged. |
swim_speed | number | 0 … 2000 | Swimming speed from up/down or jump; 0 disables swimming. |
breath | number | 0 … 600 | Seconds of air underwater; 0 disables. Sends breath on exhaustion and recovery. |
corner_correction | number | units, 0 … 64 | Player: clipping a ceiling's corner by up to this much while rising slides past it instead of ending the jump (0 off). |
air_jumps | number | 0 … 10 | Player: extra jumps in the air (1: double jump); back on landing or touching a wall (0 off). |
wall_slide | number | units/s, 0 … 100000 | Player: holding toward a wall while falling slides down it this fast at most (0: no wall slide). |
wall_jump | number | units/s, 0 … 100000 | Player: jump off a wall in the air, pushed away this fast (0: no wall jump). |
dash_speed | number | units/s, 0 … 100000 | Player: the dash button (C / controller B) throws it this fast the way it points, gravity off for dash_time (0: no dash). |
dash_time | number | s, 0.02 … 2 | Player: how long a dash lasts. |
air_dashes | number | 0 … 10 | Player: dashes in the air before landing again. |