Screen to World

Transform a position from camera viewport space to world space. The input viewport space is normalized to the camera. The bottom left of the camera viewport is (0,0) and the top right is (1,1). The Z position is in world units from the camera.
Input
Name | Data type | Description |
Screen Pos | Vec2 | The position in viewport space |
Z Depth | Number | The Z position in world units from the camera |
Camera | Camera component | The camera component that provides the input viewport space |
Output
Name | Data type | Description |
World Pos | Vec3 | The position in world space. |
Example

In this example, we use the screen to world to project the 2D touch point screen space coordinate we obtained from Screen Tap component, and use this component to control the position of a 3D cube in the world space coordinate.
Note that the Z Depth is the relative depth compared to the target camera. In the example setup, the camera is placed at Vec3 (0,0,40), we set a Z Depth of 40, then the cube’s Z will always be 0.
