Open Asterune
Ray

Ray

Represents an origin and a direction vector.

Behavior

Ray stores an origin and direction. For casts, the direction vector length specifies the maximum distance in studs.

Summary

Constructors1
Functions1
Members5
Properties3
Methods2

Constructors

new

Ray.new(origin: Vector3, direction: Vector3): Ray

Creates a ray from an origin and direction. The direction is not normalized.

Properties

Direction

Ray.Direction: Vector3

The direction vector. Its length specifies the cast range.

Origin

Ray.Origin: Vector3

The starting position.

Unit

Ray.Unit: Ray

Returns a ray with the same origin and a normalized direction. Its cast range is one stud.

Methods

ClosestPoint

Ray:ClosestPoint(point: Vector3): Vector3

Returns the point on the ray nearest to the supplied position.

Distance

Ray:Distance(point: Vector3): number

Returns the distance between a position and the nearest point on the ray.

Operators

__eq · __tostring · __type

Example

Luau
local ray = Ray.new(Vector3.new(0, 10, 0), Vector3.new(0, -100, 0))

Used by

Camera · PlayerMouse

Vector3 · Workspace · Camera · Region3