Raycast
Performs a raycast from the current camera position forward by 1000 units.
Returns:
hit(boolean): Whether the raycast hit somethingendCoords(vector3): World coordinates where the raycast endedsurfaceNormal(vector3): Normal vector of the hit surfaceentityHit(entity): The entity that was hit (if any)
Example:
local hit, endCoords, surfaceNormal, entityHit = ps.raycast()
if hit then
print("Hit something at coordinates:", endCoords)
print("Surface normal:", surfaceNormal)
if entityHit and entityHit ~= 0 then
print("Hit entity:", entityHit)
if IsEntityAVehicle(entityHit) then
print("Hit a vehicle!")
elseif IsEntityAPed(entityHit) then
print("Hit a ped!")
end
end
else
print("Raycast didn't hit anything")
endLast updated