processLineOfSight | Multi Theft Auto: Wiki Skip to content

processLineOfSight

Client-side
Server-side
Shared

This page is incomplete! Help wanted!

Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.


This function casts a ray between two points in the world, and tells you information about the point that was hit, if any. The two positions must be within the local player's draw distance as the collision data is not loaded outside this area, and the call will just fail as if the ray didn't hit.

Note

Due to a bug, shootThroughStuff argument does currently check for seeThroughStuff!

Note

Due to a bug, seeThroughStuff argument has no effect. It mistakenly checks for "shootThrough" surfaces and will always behave as if the argument is set to FALSE (It will never hit).

Syntax

processLineOfSight ( )

Code Examples

client

This example shows how you can tell what position and element the camera is looking at, up to 50 units away.

local w, h = guiGetScreenSize ()
local tx, ty, tz = getWorldFromScreenPosition ( w/2, h/2, 50 )
local px, py, pz = getCameraMatrix()
hit, x, y, z, elementHit = processLineOfSight ( px, py, pz, tx, ty, tz )
if hit then
outputChatBox ( "Looking at " .. x .. ", " .. y .. ", " .. z )
if elementHit then
outputChatBox ( "Hit element " .. getElementType(elementHit) )
end
end

See Also

World Functions