Skip to content

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:

ValueMeaning
1INCLUDE_MOVER
2INCLUDE_VEHICLE
4INCLUDE_PED
8INCLUDE_RAGDOLL
16INCLUDE_OBJECT
32INCLUDE_PICKUP
64INCLUDE_GLASS
128INCLUDE_RIVER
256INCLUDE_FOLIAGE
511INCLUDE_ALL

ShapetestIgnore:

ValueMeaning
1GLASS
2SEE_THROUGH
4NO_COLLISION
7GLASS + SEE_THROUGH + NO_COLLISION