Page tree
Skip to end of metadata
Go to start of metadata

Introduced in



Description:Returns the position in the landscape (in world coordinates), corresponding to the given point on the screen (in UI coordinates). For example, when viewing the 3D editor camera.

The command ignores all objects (such as buildings, trees, rocks, and so on), it only returns a point on the ground. While the first two syntax variations do not return reliable coordinates when the camera is pointed at the sky, the 2nd alternative (V3.4+) allows the determination of any position on the screen, by defining its distance from the camera (normally, the player).


Syntax:screenToWorld position
  • position: Position2D - 2D screen position (upper left is [0,0], lower right is [1,1]).
Return Value:Position3D - Returned height is always 0.

Alternative Syntax

Syntax:screenToWorld [position, considerSnow] (V3.3+)
  • position: Position2D - 2D screen position.
  • considerSnow: Boolean - If true, then returned position is on top of any snow layer.
Return Value:PositionATL

Alternative Syntax #2

Syntax:screenToWorld [X, Y, distance] (V3.4+)
  • X: Number - X-coordinate of 2D screen position.
  • Y: Number - Y-coordinate of 2D screen position.
  • distance: Number - Distance from the camera, extended in the direction the camera is looking.
Return Value:PositionASL - End-position of a virtual line with the specified length (distance), starting at the camera, and ending at the defined screen position. Any ground or objects in the path are ignored.


_wPos = screenToWorld [0.5,0.5];
_wPos = screenToWorld [[0.5,0.5], true];

Constantly position obj1 10m in front of the player:
waitUntil {obj1 setPosASL (screenToWorld [.5,.5,10])}

Additional Information

See also: worldToScreen, ctrlMapScreenToWorld