Movement collision response (executable, 0x140255020)
How a character’s move is resolved against the stage collision set, decoded from the floor routine 0x140255020 and the routines it calls (docs 11-10). It replaces the earlier “Wall pass” notes: the pass is not a swept cast of the move; it is a depenetration of the body at its new position, with two guards against tunnelling before it. Units: u = 0.1 m, per tick.
Body. A vertical capsule made of three spheres: radius r = w / 2, centres at the body centre c = feet + h / 2 and at c ± d, d = h / 2 − w / 2 (h = body height +0x12EA0, w = body width +0x12EA4, “Character table” 0x0C / 0x0E; the routine passes h / 2 and h / w). The mover object is the character’s member at +0x12EB0 (its +0x08 = “touched a floor” flag, +0x10 = ground attribute, +0x18 = the character, +0x28 = the probe’s world object, +0x38/+0x3C = blocking wall flag and normal).
Order per tick (after gravity and the stick/skill move have set the new position; old = last tick’s position +0x12E4C, both raised by the body centre height +0x12E98 for steps 1–2):
- Long move (length > 12.5 u): one segment cast old → new through the shared segment probe (0x140163950, world query, attribute 31 skipped). A hit replaces the new position by the hit point plus the hit triangle’s normal: a 1 u back-off (movepar 11-14, “Movement parity” section 6; the helper skips attribute 31 only). No sub-steps on this path.
- Normal move (≤ 12.5 u)
(0x140255e00): the probe sphere (radius h / 2 +
7.5 + move length) collects the nearby triangles
once, then
- a segment guard old → new over those contacts (0x140255b70, same attribute skips as below); a hit cuts the move at the face;
- sub-steps: n = int(length / 2.5) + 1; when n > 1 the move is walked in n equal steps, and after each step a small sphere of radius = the step length at the body centre is pushed out of every mesh triangle it overlaps (0x140195f30: face first when the centre’s projection is inside the triangle and the centre is in front, push = normal × (radius − distance); else the three edges, away from the nearest edge point). This loop has no attribute filter. A move shorter than 2.5 u has no sub-steps.
- Probe refresh: the probe sphere is set to the capsule centre c with radius h / 2 + 7.5 + 15 (long move) or reused from step 2, and queried again (0x1401d5860).
- Round arena limit (0x1402559f0, only when the stage number mod 10 = 1): when the horizontal distance of c from the stage origin plus w is over 150 u, the body is put back on the circle of radius 150 − w around the origin (and the inward direction is recorded as a blocking wall when the move ran into it).
- Face pass (0x1401959c0,
once per contact triangle, in contact-list
order; each run sees the position the previous
ones left):
- skipped contacts: not a mesh triangle; attribute 31; attribute 20 while the reaction state is 5 or 7 (“Collision attributes” below); the body centre behind the face (one-sided); a wall face (normal y ≤ 0.643) whose three corners are all lower than feet + 7.5 u while the floor flag is set;
- for each of the three spheres (centre, lower, upper, in that order): the segment sphere centre → centre − normal × r is tested against the triangle (0x140194210: endpoints on opposite sides of the plane and the crossing inside the three edges). On a hit the penetration is p = r − distance of the sphere centre to the plane;
- floor face (normal y > 0.643): the body is lifted straight up by p (no sideways move) and the floor flag is set for the rest of the tick;
- wall face: when the contact point (the sphere centre’s projection on the plane) is lower than feet + 7.5 u, a second probe is made at height feet + 7.5 u from the body axis toward the face along the face’s horizontal normal, length r; if it misses, the triangle is dropped at once (the step-over: anything that ends lower than 0.75 m over the feet does not block). Otherwise the body moves by normal × p (the full 3-D normal, so a leaning wall also lifts or presses the body). Sliding is only this projection: the move’s component into the wall is removed, the rest stays.
- blocking wall: after a wall push, when normal · (horizontal move direction) < −0.643 the triangle is a head-on wall; the most head-on one of the tick is stored (mover +0x3C) and the character’s flag +0x12E8C is set (its readers were not followed: lead for “run into a wall” behaviour).
- Edge pass (0x140195580, a second loop over the same contacts and skips): wall faces only (normal y ≤ 0.643), front side, same 7.5 u low-face skip. For each sphere whose face test misses, each of the three edges: nearest point on the edge (0x140193fd0); when it is closer than r (and not lower than feet + 7.5 u while the floor flag is set) the sphere is pushed away from that point to distance r. Same blocking-wall record.
- Floor pick (“Floor test” above) over the same contacts; it also copies the taken floor contact’s attribute to the ground attribute (below) and writes the position back.
There is one pass of each loop per tick: no iteration to convergence and no velocity change (the horizontal speed is whatever the stick/skill code sets next tick; only the position is corrected). Order dependence between triangles is real (list order of the world query).
Confidence: M throughout (every rule and constant was read in the code; none has been checked against footage or a run yet), except the capsule sizes’ source and the 7.5 u / 0.643 constants, which the floor test already uses (H).
Step-up. There is no separate step-up: wall faces and edges lower than 0.75 m over the feet are ignored and the floor pick then lifts the body onto the higher floor (its window is h / 2 + 9 u above the feet). Operands checked (playfix 11-15, H): the face pass computes its gate as the passed position’s y − the passed half height + 7.5 (constant 0x1402f7f58); the caller (0x1402554cc in 0x140255e00) passes the feet + h / 2 (character +0x12E44 plus +0x12EA0 × 0.5) and h / 2, so the gate is feet + 7.5 u exactly. The Palace ground-floor low boxes (attribute 8, 4.2 u tall, st03 meshes 382 / 677) are under it: the game’s rules step onto them (played: our Player rises 0.39 m onto the east one); the central 12 u attribute-18 ring blocks on all four sides.
Body push between characters (player class virtual method 0x140250780; formula M: read in the code; place in the tick H for the order, read in the code (docs 11-12, doc-body)).
Where it runs. The character tick 0x14024ecf0 splits on C + 0x34 (≠ 0: simulated on this machine, a local human or a CPU; 0: driven by the network):
- local: input and requests (0x1402526c0, only while active + alive), the movement state machine 0x140256e80 (it sets this tick’s wanted position C + 0x12E40 from stick, skill moves, knockback), then, only while C + 0x28 ≠ 0 and the character’s own player slot (C + 0x14) is registered and active (or on the test stage 0x7777): 0x140257510 and the movement step 0x140254590 (called at 0x14024eef7);
- network-driven: 0x140254fa0 and the remote state (0x14018f330), then 0x1402593c0. No push, no collision response: a remote body is placed by its owner’s messages.
Order inside the movement step 0x140254590:
- body push (virtual slot 0x70 of the player class table 0x14048e3b0), always first;
- virtual slot 0x80 (0x140250cd0), only while the match phase global 0x1404bc950 ≠ 0: for a locally simulated character, the test against category 0x400 attack bodies (flying pieces, the break sphere). Decoded in “Stage attack bodies and landings”; no position change;
- gravity, skipped in action state 0xB (C + 0x12F04): fall speed C + 0x12E84 −= C + 0x12E80, floored at the constant 0x1402f8330 (set to −7.5 u/tick when lower), added to the position’s y (the existing “Player movement” notes);
- the collision response 0x140255020 above (on stage 0x7777: a flat floor at y = 0), after clearing the blocking-wall flag C + 0x12E8C;
- landing / leaving-ground bookkeeping.
So the push displaces the wanted position before gravity and the wall / floor response of the same tick: a body pushed into a wall is put back by the face and edge passes at once and is never left inside geometry; the push itself never changes heights.
Rule. For the own character s (must be active C + 0x20 ≠ 0 and alive C + 0x24 ≠ 0, else nothing) and each of the four player slots o other than its own (o exists, active, alive, o’s + 0x10 = 0):
- vertical overlap: |c_o.y − c_s.y| < h_o / 2 + h_s / 2 (centres = feet + h / 2);
- horizontal distance dist < R, R = (w_o + w_s) / 2;
- dir = horizontal unit vector from s to o ((1, 0, 0) when dist = 0), overlap = R − dist;
- o simulated on this machine (its +0x34 ≠ 0): s moves by −dir × overlap / 2 and o by +dir × overlap / 2 (o’s stored position is changed here, in s’s tick);
- o driven by the network (+0x34 = 0): s alone moves by −dir × overlap. Slots are visited 0..3 in order and each pair uses the positions the earlier ones left. State check: none besides active / alive / the +0x10 flag: no reaction-state, skill or invulnerability test in the routine or where it is invoked (a lying, thrown or casting body pushes and is pushed like any other). Since two local bodies each run the push in their own tick, a local pair is separated in the first of the two ticks (half each) and the second finds no overlap left. With every playable width 10 u, R is 10 u (1.0 m). A second class does the same at 0x14012f574 (story bosses).
Implementation notes for the rebuild
- (movecoll: built as
PdBodyMove, called fromplayer.gd_move_body; tests test_movecoll.gd and the net-movecoll autotest; what stays inferred is in PLACEHOLDERS “Wall collision response and step-up”.) - Replace the CharacterBody3D slide + STEP_MAX
step-up by the decoded passes on the
collision.jsontriangles: guard, sub-steps (2.5 u), face pass, edge pass, floor pick, in this order, one pass each, in the converter’s mesh/triangle order (the world query walks the object list; exact list order between objects is not decoded, M). - Capsule from the character table: r = width / 2, d = height / 2 − width / 2; constants 7.5 u (step-over), 0.643 (floor/wall split and head-on test), 12.5 u (long move), 2.5 u (sub-step), 150 u (round arena, stages x1 only).
- Body push: the formula above, run for each
locally simulated character at the start of its
movement step: after the state machine has set
the tick’s wanted position, before gravity and
before the collision passes; no state gate. In
netplay the local player takes the whole overlap
against a remote body (each peer does this for
its own character) and remote bodies get neither
push nor response. (movecoll r2: our
host-authoritative netplay carries the client’s
own push in its input, PlayerInput
body_push, and the host’s copy of the client’s body applies that instead of pushing itself.) - Body sizes per character: the “Body numbers per character” table (“Character table”): playable width 1.0 m, centre 0.9 m, height 1.8 / 1.9 / 2.0 m by model.
- Remove the 3-tick “step-up while falling” cut-off: the game has no such rule; a falling body is stopped by a ledge’s wall face only when the face reaches 0.75 m over its feet.