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
| Type | Name | Description |
|---|---|---|
vector2 | position | Position on the screen in pixels |
Returns
| Type | Name | Description |
|---|---|---|
vector3 | result | Normalized direction vector from the camera through the given screen point |
Examples
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))