Raycast

Library
Updated 2 months ago · v1.3.7
i

Client Module

lib.raycast.fromCoords

Casts a ray between two world coordinates and returns collision data.

lua
local hit, endCoords, entityHit, surfaceNormal, materialHash = lib.raycast.fromCoords(coords, destination, flags, ignore)
ParameterTypeRequiredDescription
coordsvector3yesStart position
destinationvector3yesEnd position
flagsnumbernoShapetest flags (default: 511 ALL)
ignorenumbernoShapetest 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.

lua
local hit, endCoords, entityHit, surfaceNormal, materialHash = lib.raycast.fromCamera(flags, ignore, distance, cam)
ParameterTypeRequiredDescription
flagsnumbernoShapetest flags (default: 511)
ignorenumbernoShapetest ignore flags (default: 4)
distancenumbernoMax ray distance (default: 1000.0)
camnumbernoCamera handle (default: gameplay camera)

lib.raycast.world3dToScreen2d

Converts a 3D world position to 2D screen coordinates.

lua
local screenPos = lib.raycast.world3dToScreen2d(pos) -- vector2

Shapetest Flags

ValueFlag
1MOVER
2VEHICLE
4PED
8RAGDOLL
16OBJECT
32PICKUP
64GLASS
128RIVER
256FOLIAGE
511ALL

Shapetest Ignore

ValueFlag
1GLASS
2SEE_THROUGH
3GLASS + SEE_THROUGH
4NO_COLLISION
7ALL
Was this page helpful?
This page was last updated on 12 March 2026
DIRKSCRIPTS
All you need for your FiveM server.10% off your first order

Unsubscribe any time.

Copyright © 2026 DirkScripts. Not affiliated with or endorsed by Rockstar North or Take-Two Interactive.