processLineOfSight
Client
Casts a ray between two points and returns the first thing it hits.
bool, vec3, vec3, element|nil processLineOfSight(float startX, startY, startZ, float endX, endY, endZ [, bool checkBuildings = true, bool checkVehicles = true, bool checkPeds = true, bool checkObjects = true])
Parameters
| Name | Type | Description |
|---|---|---|
| startX, startY, startZ | float | Where the ray starts. A vec3 also works. |
| endX, endY, endZ | float | Where the ray ends. A vec3 also works. |
| checkBuildings | bool | Whether buildings count.default true |
| checkVehicles | bool | Whether vehicles count.default true |
| checkPeds | bool | Whether peds count.default true |
| checkObjects | bool | Whether objects count.default true |
Returns
false if nothing was hit. Otherwise true, the hit point, the surface normal there and the element hit (nil when it is not an element, such as a map building).
Example
local function firstHit(from, to)
local hit, position, normal, element = processLineOfSight(from, to, true, true, false, true)
if hit and element then
outputDebugString("Hit a " .. getElementType(element))
end
return hit and position
end