Physics · interface

SurfaceHit

Explained in Your first game, Rigid bodies.

interface SurfaceHit
import type { SurfaceHit } from '@driftengine/physics';

Properties

NameTypeDescription
ynumberHeight of the surface in the queried column.
normalXnumber
normalYnumber
normalZnumber
tangentXnumberDirection of travel at the nearest point on the centreline.
tangentYnumber
tangentZnumber
distanceMnumberArc length of that nearest point. How far along the route you are.
lateralMnumberSigned offset from the centreline, positive to the character's right.
halfWidthMnumberHalf the surface's width here — how much room is left before the edge.
bankRadnumber
tiltXnumberWhich way up looks here — the ruled surface's own normal, not the cross-section's.
More

A separate field because it answers a separate question. normal is the ground a character stands on and every movement rule is tuned against it: how steep is this to walk, which way does gravity pull along it, is it floor or is it wall. That question is about the cross-section, and its answer is the same all the way across the deck.

This one is about how the surface looks where you are standing on it, and on a deck whose bank rolls it is a very different number: the ruled surface climbs far more steeply along the route near its edges than the centreline does — 57° measured on one chicane against the centreline's 11°, and past vertical on a chute. Correct geometry, and correct for orienting a body that has to look like it is on the deck. Fed to the walking rules instead it takes the ground away: a character met a chicane's edge as a wall and fell down it at 20 m/s a hand's width above the deck, never landing, which is exactly what flying looks like.

tiltYnumber
tiltZnumber