Ray

A ray has one origin point in the 3D scene and a direction. It returns potentials Impacts and the distance from the origin when that happens.

Constructors

Ray ( Number3 origin, Number3 direction )

Creates a Ray with an origin and a direction.

local ray = Ray(Camera.Position, Camera.Forward)
local impact = ray:Cast()

Functions

Casts a ray and returns an Impact (can be nil).

The Impact contains information about what's been hit.

Pointer.Down = function( pointerEvent )
    local ray = Ray(pointerEvent.Position, pointerEvent.Direction)
    local impact = ray:Cast()
    if impact.Block ~= nil then
      print("block hit:", impact.Block)
    end
end

Properties

The direction of the ray, in world coordinate system.

The origin of the ray, in world coordinate system.