Skip to content

Ray

Supported Datatype

Represents a line with a starting point that casts infinitely in a specific direction.

Description

The Ray data type represents 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

new Supported Returns a Ray with the given Origin and Direction.
Ray.new(Origin: Vector3, Direction: Vector3)

Returns a Ray with the given Origin and Direction.

Returns a new Ray with given Origin and Direction.

Properties

Unit Supported The Ray with a normalized direction (the direction has a magnitude of 1).
Ray.Unit()

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

Origin Supported The position of the origin.
Ray.Origin()

The position of the origin.

Direction Supported The direction vector of the Ray.
Ray.Direction()

The direction vector of the Ray.

Methods

ClosestPoint Supported Returns a Vector3 projected onto the ray so that it is within the Ray line of sight.
Ray:ClosestPoint(point: Vector3)

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

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

Distance Supported Returns the distance between the given point and the closest point on the Ray.
Ray:Distance(point: Vector3)

Returns the distance between the given point and the closest point on the Ray.

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

Nova binding inventory

Library Members
new ClosestPoint, Direction, Distance, Origin, Unit, unit

Roblox reference: Ray