self:project_position
Client
Returns the world-space position of a point at a given depth from a viewport position
Syntax
local world_position = self:project_position(
position,
depth
)Parameters
| Type | Name | Description |
|---|---|---|
vector2 | position | Viewport position to project from as {x, y} |
float | depth | Depth distance along the ray from the camera |
Returns
| Type | Name | Description |
|---|---|---|
vector3 | world_position | Resulting world-space position as {x, y, z} |
Examples
local entity = core.camera.create()
entity:set_active()
local world_pos = entity:project_position({960, 540}, 10)
core.engine.print("info", "World position:", util.table.unpack(world_pos))