Floor test (executable)
The per-tick character update (after the
stick and skills have set the horizontal move)
runs: vy -= g,
vy = max(vy, -7.5),
y += vy, then the floor
routine:
- The wall passes at the new position (the body as a capsule of three spheres: “Movement collision response” below).
- Floor candidates: stage
collision triangles of the floor kind (two other
kinds are skipped in some states) whose x/z
projection contains the body’s (x, z) and whose
normal has y > 0.1. For
each, the plane’s height at (x, z) is
p = p0.y − (n.x (x − p0.x) + n.z (z − p0.z)) / n.y. - A candidate is taken when it is higher than
the best so far and below
feet + h / 2 + 9 units, h being the character’s body height (the one the body push uses, SYSTEMS.md §9). The best starts at- feet − (7.5 units + this tick’s horizontal move) when the body was on the ground last tick (it keeps to floors up to 0.75 m plus its move below: walking down stairs and slopes never leaves the floor),
- feet when it was in the air (it lands only on floors its feet passed through).
- Ground when a taken candidate has normal y > 0.643 (about 50 degrees); then the feet are set to the best height and the routine reports “on the floor”. A steeper (0.1–0.643) candidate can be the best height but doesn’t ground the body. The same window applies in the air: a falling body is lifted onto a floor up to h / 2 + 0.9 m above its feet if the wall pass let it get over it.
- h (and the radius, and two more size values)
come from the per-character table built from
charaset.dat(decoded: “Character table”; h is 18–20 units for the playable cast).
Leaving the ground. The body
keeps an “on the ground” flag. On the floor:
vy = 0 and the floor height is
remembered. When the floor test finds nothing
(beyond the 0.75 m snap), the flag stays set
while gravity pulls the body down, until
its feet are more than 5 units (0.5 m) under the
remembered floor height; only then is
it in the air (air animation, landing by drop
height on the next floor). In some character
states (casts and similar, not mapped) a body
that loses the floor is put back where it was
instead (it can’t walk off an edge then). With
the flag clear, a tick where the floor test
reports the floor and vy ≤ 0 is the
landing (vy = 0, landing animation
by the drop from the highest point, “Movement
animations”).
Rebuild: the floor pick is
step 7 of PdBodyMove.resolve (the
window from
PdMovement.snap_down()’s 0.75 m +
move, FLOOR_NORMAL_Y), the ground
flag and LEAVE_DROP are in
player.gd _move_body; the geometry
is the game’s own collision set (“Stage
collision” below) and the response is the
decoded one (“Movement collision response”,
built (movecoll)).