PcoWSkbVqDnWTu_dm2ix
The Developer Hub is now deprecated and information on this page may no longer be accurate. To see our new and improved documentation, please click here. You can read more about the future of documentation here.
Collapse Sidebar

Ray

A Ray is a half-line, finite in one direction but infinite in the other. It can be defined by a 3D point, where the line originates from, and a direction vector, which is the direction it goes in.

Constructors

Ray.new ( Vector3 Origin, Vector3 Direction )

Creates a new Ray with given Origin and Direction

Properties

Ray Ray.Unit

The Ray with a normalized direction (the direction will have a magnitude of 1).

Vector3 Ray.Origin

The position of the origin.

Vector3 Ray.Direction

The direction vector of the Ray.

Functions

Vector3 Ray:ClosestPoint ( Vector3 point )

Returns a Vector3 projected onto the ray so that it is within the Ray’s line of sight.

Note: the Ray must be a unit ray for this method to behave as expected!

number Ray:Distance ( Vector3 point )

Returns the distance between the given point and the point on the ray nearest to the given point (Ray:ClosestPoint(point)).