PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

Ray

A Ray is a half-line, that is 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.

You can identify BasePart|BaseParts intersecting a Ray using Workspace/FindPartOnRay and its alternatives, for more information see Workspace.

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

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.

number Ray:Distance ( Vector3 point )

Returns the distance between the Ray’s origin and Ray:ClosestPoint(point)