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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
source |
QuerySource |
options |
CastRayOptions |
Returns
Section titled “Returns”RayHitResult | null
Example
Section titled “Example”const hit = castRay(step, { from, direction: down, maxDistance: 1.2, collisionMask: [CoreLayers.ground] });