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

TypeNameDescription
vector2positionViewport position to project from as {x, y}
floatdepthDepth distance along the ray from the camera

Returns

TypeNameDescription
vector3world_positionResulting world-space position as {x, y, z}

Examples

Project a viewport position to world space at a given depth
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))

On this page