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
Name | Type | Description |
---|---|---|
origin | Vector3 or Vector3Array | The origin point of the raycast. |
dir | Vector3 or Vector3Array | The direction of the raycast. |
far | number or null | The 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) | RaycastOptions | Additional options for the raycast. |
Returns
IntersectsResult
- The result of the raycast.
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