getWorldFromScreenPosition
Client
Turns a screen point, at a depth, into a world point, with the current frame's camera.
vec3 getWorldFromScreenPosition(float x, y, depth)
Parameters
| Name | Type | Description |
|---|---|---|
| x, y, depth | float | The screen coordinates in pixels and the distance from the camera along its view direction, in metres. A vec3 also works. |
Returns
The point in the world.
Example
local sx, sy = getScreenSize()
local ahead = getWorldFromScreenPosition(sx / 2, sy / 2, 50)
outputDebugString(("50 m ahead: %.1f, %.1f, %.1f"):format(ahead.x, ahead.y, ahead.z))