Screen to World
Use Screen to World to 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. Screen to World is in the Transform category.
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
This example uses Screen to World to project the 2D touch point screen space coordinate obtained from the Screen Tap component, and uses this component to control the position of a 3D cube in the world space coordinate.
The Z Depth is the relative depth compared to the target camera. In this example, the camera is placed at Vec3 (0,0,40). The Z Depth is set to 40, so the cube’s Z will always be 0.