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): booleanimport { raycastWorld } from '@driftengine/physics';Parameters
| Parameter | Type | Description |
|---|---|---|
bodies | BodySet | |
tree | DynamicTree | |
ox | number | |
oy | number | |
oz | number | |
dx | number | |
dy | number | |
dz | number | |
maxDistance | number | |
out | RayHit | |
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.