self:project_ray_normal

Client

Retrieves a normalized direction vector from the camera through a given screen point


Syntax

local result = self:project_ray_normal(
    position
)

Parameters

TypeNameDescription
vector2positionPosition on the screen in pixels

Returns

TypeNameDescription
vector3resultNormalized direction vector from the camera through the given screen point

Examples

Get a ray direction from the screen center
local resolution = core.engine.get_resolution()
local center = {resolution[1]*0.5, resolution[2]*0.5}
local entity = core.camera.create()

entity:set_active()

local ray_normal = entity:project_ray_normal(center)

core.engine.print("info", "Ray direction:", util.table.unpack(ray_normal))

On this page