getScreenFromWorldPosition | Multi Theft Auto: Wiki Skip to content

getScreenFromWorldPosition

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 gets the screen position of a point in the world. This is useful for attaching 2D gui elements to parts of the world (e.g. players) or detecting if a point is on the screen (though it does not check if it is actually visible, you should use processLineOfSight for that).

Syntax

getScreenFromWorldPosition ( )

Code Examples

client

This example add a '3d' text at coordinates 0, 0, 0 (center of map).

addEventHandler ( "onClientRender", root,
function ( )
if ( getDistanceBetweenPoints3D ( 0, 0, 3, getElementPosition ( localPlayer ) ) ) < 50 then
local coords = { getScreenFromWorldPosition ( 0, 0, 3 ) }
if coords[1] and coords[2] then
dxDrawText ( "Hello !", coords[1], coords[2], coords[1], coords[2], tocolor(255,255,255), 1, "default-bold" )
end
end
end )

See Also

World Functions