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

castRay

castRay(source, options): RayHitResult | null

The nearest collider a ray meets, named by its entity, or null where it meets none within maxDistance: a lap gate’s line, a turret’s sight, a gun’s first hit. As near as another, the lower entity id wins, as castRayAll orders them. Through the step in a system, which meets the tick as its systems wrote it, or the world in a view, which meets the scene as the last step left it. The result is pooled: valid until the system returns, or in a view until the next query.

Parameter Type
source QuerySource
options CastRayOptions

RayHitResult | null

const hit = castRay(step, { from, direction: down, maxDistance: 1.2, collisionMask: [CoreLayers.ground] });