Library
Raycast
Utility functions for performing raycasts in 3D space.
Client Functions
FromCoords
Casts a ray from the specified coordinates toward the destination and returns collision data.
dLib.Raycast.FromCoords(coords, destination, flags, ignore, ignoreEntity)| Argument | Type | Description |
|---|---|---|
coords? | vector3 | Starting position of the ray in world coordinates. |
destination? | vector3 | End position of the ray in world coordinates. |
flags? | table | nil | Collision flags to filter what the ray should hit. Defaults to 511. |
ignore? | string | nil | A bit mask with bits 1, 2, 4, or 7 relating to collider types. 4 and 7 are usually used. Defaults to 4. |
ignoreEntity? | number | nil | Additional entity handle to ignore, typically the player or their vehicle. |
| Returned Data | Type | Description |
|---|---|---|
hit | boolean | Whether the ray hit something. |
entityHit | number | nil | Entity handle of the hit object, if any. |
endCoords | vector3 | World coordinates where the ray stopped. |
surfaceNormal | vector3 | Surface normal vector at the hit point. |
materialHash | number | Material hash of the surface that was hit. |
FromCamera
Casts a ray from the player's camera in the aiming direction and returns collision data.
dLib.Raycast.FromCamera(distance, flags, ignore, ignoreEntity)| Argument | Type | Description |
|---|---|---|
distance? | number | nil | Maximum distance the ray should travel. Defaults to 10. |
flags? | table | nil | Collision flags to filter what the ray should hit. Defaults to 511. |
ignore? | string | nil | A bit mask with bits 1, 2, 4, or 7 relating to collider types. 4 and 7 are usually used. Defaults to 4. |
ignoreEntity? | number | nil | Additional entity handle to ignore, typically the player or their vehicle. |
| Returned Data | Type | Description |
|---|---|---|
hit | boolean | Whether the ray hit something. |
entityHit | number | nil | Entity handle of the hit object, if any. |
endCoords | vector3 | World coordinates where the ray stopped. |
surfaceNormal | vector3 | Surface normal vector at the hit point. |
materialHash | number | Material hash of the surface that was hit. |