Skip to content
Work in progress. These docs describe Spawnite at launch, and some parts are still being built.

castShape

castShape(source, options): ShapeHitResult | null

The nearest collider shape meets moving from from along direction within maxDistance, named by its entity, with the point on the shape that touched; null where it meets none. A shape that starts inside a collider meets it at distance 0 where its move leads further in, and passes through it where the move leads out, as Rapier’s cast does, so a camera swept off a wall it rests on is not held at the wall. Pooled, as castRay’s result is.

Parameter Type
source QuerySource
options CastShapeOptions

ShapeHitResult | null

const swept = castShape(step, { shape: capsule({ radius: 0.3, height: 1.2 }), from, direction, maxDistance: 2, ignore: [character] });