Skip to content

WorldToScreen

Where a world point lands in the elements’ space.

The same space CreateUiText and SetUiPos place things in (1080 rows high, GetScreenSize wide), so a label put at the answer sits over the point. A point beside the screen gives a place outside it (below 0 or beyond the width or the height); nil means behind the camera. The camera is the one of the frame just drawn: a label that follows a point in OnFrame trails a fast turn by a frame.

WorldToScreen(x, y, z)
Parameter Type
x number metres
y number metres
z number metres

number|nil, number|nil - sx, sy - the point’s place, or nil when it is behind the camera

function OnFrame()
local sx, sy = WorldToScreen(1240, 2130, 41)
if sx then SetUiPos("flag", sx, sy - 40) ShowUiElement("flag") else HideUiElement("flag") end
end

GetScreenSize · OnFrame · the The game’s UI for a script group of the index