hytopia
Version:
The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.
108 lines (50 loc) • 1.37 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [server](./server.md) > [Simulation](./server.simulation.md) > [raycast](./server.simulation.raycast.md)
## Simulation.raycast() method
Casts a ray through the simulation.
**Signature:**
```typescript
raycast(origin: RAPIER.Vector3, direction: RAPIER.Vector3, length: number, options?: RaycastOptions): RaycastHit | null;
```
## Parameters
<table><thead><tr><th>
Parameter
</th><th>
Type
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
origin
</td><td>
RAPIER.Vector3
</td><td>
The origin of the ray.
</td></tr>
<tr><td>
direction
</td><td>
RAPIER.Vector3
</td><td>
The direction of the ray.
</td></tr>
<tr><td>
length
</td><td>
number
</td><td>
The length of the ray.
</td></tr>
<tr><td>
options
</td><td>
[RaycastOptions](./server.raycastoptions.md)
</td><td>
_(Optional)_ The options for the raycast.
</td></tr>
</tbody></table>
**Returns:**
[RaycastHit](./server.raycasthit.md) \| null
A RaycastHit object containing the first block or entity hit by the ray, or null if no hit.
## Remarks
The cast ray will stop at the the first block or entity hit within the length of the ray.