DirkScripts
Docs
Raycast
βΉοΈ Client Module
#lib.raycast.fromCoords
Casts a ray between two world coordinates and returns collision data.
lualocal hit, endCoords, entityHit, surfaceNormal, materialHash = lib.raycast.fromCoords(coords, destination, flags, ignore)
| Parameter | Type | Required | Description |
|---|---|---|---|
| coords | vector3 | yes | Start position |
| destination | vector3 | yes | End position |
| flags | number | no | Shapetest flags (default: 511 ALL) |
| ignore | number | no | Shapetest ignore flags (default: 4 NO_COLLISION) |
Returns: hit: boolean, endCoords: vector3, entityHit: number, surfaceNormal: vector3, materialHash: number
#lib.raycast.fromCamera
Casts a ray from the camera through the crosshair.
lualocal hit, endCoords, entityHit, surfaceNormal, materialHash = lib.raycast.fromCamera(flags, ignore, distance, cam)
| Parameter | Type | Required | Description |
|---|---|---|---|
| flags | number | no | Shapetest flags (default: 511) |
| ignore | number | no | Shapetest ignore flags (default: 4) |
| distance | number | no | Max ray distance (default: 1000.0) |
| cam | number | no | Camera handle (default: gameplay camera) |
#lib.raycast.world3dToScreen2d
Converts a 3D world position to 2D screen coordinates.
lualocal screenPos = lib.raycast.world3dToScreen2d(pos) -- vector2
#Shapetest Flags
| Value | Flag |
|---|---|
| 1 | MOVER |
| 2 | VEHICLE |
| 4 | PED |
| 8 | RAGDOLL |
| 16 | OBJECT |
| 32 | PICKUP |
| 64 | GLASS |
| 128 | RIVER |
| 256 | FOLIAGE |
| 511 | ALL |
#Shapetest Ignore
| Value | Flag |
|---|---|
| 1 | GLASS |
| 2 | SEE_THROUGH |
| 3 | GLASS + SEE_THROUGH |
| 4 | NO_COLLISION |
| 7 | ALL |
