Physics · function

raycastWorld

The nearest body a ray meets, or false if it meets none.

Explained in Your first game, Rigid bodies.

function raycastWorld(bodies: BodySet, tree: DynamicTree, ox: number, oy: number, oz: number, dx: number, dy: number, dz: number, maxDistance: number, out: RayHit, filter?: QueryFilter): boolean
import { raycastWorld } from '@driftengine/physics';

Parameters

ParameterTypeDescription
bodiesBodySet
treeDynamicTree
oxnumber
oynumber
oznumber
dxnumber
dynumber
dznumber
maxDistancenumber
outRayHit
filter?QueryFilter

In depth

A ray starting inside a body reports that body at fraction zero, with the normal of the face it is nearest to leaving through. Reporting nothing instead is the tempting alternative and is worse: a line-of-sight test would then say a wall it started inside was not there.