self:project_ray_normal

Client

Returns the normalised direction of a ray cast from the camera through a viewport position in world space


Syntax

local normal = self:project_ray_normal(
    position
)

Parameters

TypeNameDescription
vector2positionViewport position to project the ray from as {x, y}

Returns

TypeNameDescription
vector3normalNormalised ray direction in world space as {x, y, z}

Examples

Get a ray direction from viewport center
local entity = core.camera.create()
entity:set_active()

local ray = entity:project_ray_normal({960, 540})
core.engine.print("info", "Ray direction:", util.table.unpack(ray))

On this page