Physics · interface

WorldOpinion

What the world knows that its colliders do not.

Explained in Your first game, Rigid bodies.

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

In depth

Declared structurally, so nothing is imported in either direction.

Methods

blocked

blocked(axis: Axis, from: number): boolean

Is there a face standing where the body has just moved to, that it can neither step onto nor pass under? from is where it started on axis.

ParameterTypeDescription
axisAxis
fromnumber
More

The case this exists for: a deck drawn as a smooth surface carries no collision boxes, so every one of its edges is scenery. A body walks into the side of a raised slab and keeps going, which looks exactly like clipping through the world because it is.

riseTo

riseTo(x: number, z: number, feetY: number): number | null

How far the world's own surface would rise to meet a body standing at (x, z) with its feet at feetY, or null where it has no opinion. Negative for a descent.

ParameterTypeDescription
xnumber
znumber
feetYnumber

vouches

vouches(): boolean

Whether the world vouches for its own rises here.

More

The retry below overrules a collider that refused a move, on the grounds that the surface says the ground rises to meet it. That is right on ground the world authored as travelable and wrong everywhere else: a terrace wall, a station lip and a courtyard edge are real, intended walls and the hull is the only honest answer for them. A consumer with no such distinction answers the same thing every time and pays nothing.