Walkers: standing on things under physics
Skill ferret-physics-walkers · download all skills · SKILL.md
When to use#
Always, for anything that stands or walks: a crowd on a beach and a mole, men on a ship's deck, crew walking about a lifeboat, NPCs on a moving platform. Every Ferret scene rests on the engine's physics unless it says otherwise: nobody is in the air, below a deck or inside a hull; a man in the air falls into the water, a man on a deck rests on it. Do not write y = table[x][z], do not interpolate heights between points by hand, do not move people on paths that can leave them off the ground.
The model#
Walkers (in @ferret/physics) holds Supports and steps Walkers: carry with the support, move by the wanted (dx, dz) if ground and walls allow (slide along walls), step up 0.45 and down 0.6, otherwise fall with g, splash and sink in water, land on the next support. FieldSupport (a function), GridSupport (cells read off a model, own frame, moves, range), StripSupport (a gangway, lies on over its ends, passes walls).
Steps#
- One
Walkersfor the scene, with the ground as aFieldSupportandwater: () => seaLevel. - A ship, boat or platform: read its model with rays on a grid (several layers per ray, in its own frame) into a
GridSupport, give it aframe(world <-> node) and arange; push it intowalkers.supports, remove it when the craft goes. - A gangway or ramp: a
StripSupportlaid from the quay edge to the deck in the same step that sends the men over it. - Each person gets a
Walker(placeon the ground,mounton a moving deck); each step:walkers.step(w, dt, dx, dz, true)and copyx, y, zout. The AI decides where to go; the physics decides where he can be. - React to
splash,blocked,swim: give up a target when blocked; a man afloat (w.swim) swims toward the shallows by passing (dx, dz); never move anyone by hand. - Test with the pure
Walkers(no engine): falls onto a deck, off an edge into water, a wall stops, a rolling deck carries, a gangway is crossed.
Check afterwards#
A probe over a few minutes of the running scene: nobody in the air, nobody below the surface under his feet, men over the side only when the scene meant it; screenshots of the decks and the gangway.
What usually goes wrong#
- Men fall through a moving deck: its matrix and
rangewere not updated together this frame. - Men left in the air when the ship sails: they stood on a world-fixed gangway; the support with a frame wins ties, make the gangway overlap the deck.
- Crew fall into a hole in the model: the target needs a path the support does not have; use waypoints,
careful: true, give up onblocked. - Men step off the gangway sideways at its foot: they were told to walk along the rail; send them inboard first.
- A scene with hand-placed heights "works" until something moves under it: that is the bug, not the scene.
Files#
reference/walkers.md— People and other points that stand on things, under gravity, with walls and water, cheap enough for thousands. Every scene rests on this unless it says otherwise.reference/api-physics.md— every export of@ferret/physicswith signature and doc commentreference/api-physics-2.md— every export of@ferret/physicswith signature and doc commentreference/commands.md— 7 commands of these packages with their arguments