Skip to main content

raycastPoint

Casts a ray from a origin and a direction in the world and returns the hit information.

Syntax

engine.world.raycaster.raycastPoint(origin, dir, far, options);

Parameters

NameTypeDescription
originVector3 or Vector3ArrayThe origin point of the raycast.
dirVector3 or Vector3ArrayThe direction of the raycast.
farnumber or nullThe maximum distance the ray can travel before it is considered to have missed its target. If null, then there is no maximum distance limit.
options (optional)RaycastOptionsAdditional options for the raycast.

Returns

Example

const intersects = engine.world.raycaster.raycastPoint(
engine.localPlayer.position, // origin
[0, -1, 0], // dir - ray to the ground
10, // far - how far to cast the ray
{
excludePlayerIds: [engine.localPlayer.id], // exclude the local player
},
);

console.log('what did we hit?', intersects);

Available on: Client