st.raycast — Raycasting (Client)
lua
-- Raycast from coordinates to destination
---@return boolean hit
---@return number entityHit
---@return vector3 endCoords
---@return vector3 surfaceNormal
---@return number materialHash
local hit, entity, endCoords, normal, material = st.raycast.fromCoords(
coords, -- vector3 origin
destination, -- vector3 destination
flags, -- ShapetestFlags? default 511 (all)
ignore -- ShapetestIgnore? default 4 (no collision)
)
-- Raycast from the camera forward
local hit, entity, endCoords, normal, material = st.raycast.fromCamera(
flags, -- ShapetestFlags? default 511
ignore, -- ShapetestIgnore? default 4
distance -- number? default 10
)ShapetestFlags:
| Value | Meaning |
|---|---|
| 1 | INCLUDE_MOVER |
| 2 | INCLUDE_VEHICLE |
| 4 | INCLUDE_PED |
| 8 | INCLUDE_RAGDOLL |
| 16 | INCLUDE_OBJECT |
| 32 | INCLUDE_PICKUP |
| 64 | INCLUDE_GLASS |
| 128 | INCLUDE_RIVER |
| 256 | INCLUDE_FOLIAGE |
| 511 | INCLUDE_ALL |
ShapetestIgnore:
| Value | Meaning |
|---|---|
| 1 | GLASS |
| 2 | SEE_THROUGH |
| 4 | NO_COLLISION |
| 7 | GLASS + SEE_THROUGH + NO_COLLISION |