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
The direction vector.
The starting position.
Returns a ray with the same origin and a normalized direction.
ClosestPoint(point: Vector3): Vector3Returns the point on the ray nearest to the supplied position.
Returns the distance between a position and the nearest point on the ray.
Constructors
new
Creates a ray from an origin and direction. The direction is not normalized.
Properties
Direction
Ray.Direction: Vector3The direction vector. Its length specifies the cast range.
Origin
Ray.Origin: Vector3The starting position.
Unit
Ray.Unit: RayReturns a ray with the same origin and a normalized direction. Its cast range is one stud.
Methods
ClosestPoint
Returns the point on the ray nearest to the supplied position.
Distance
Ray:Distance(point: Vector3): numberReturns the distance between a position and the nearest point on the ray.
Operators
__eq · __tostring · __type
Example
local ray = Ray.new(Vector3.new(0, 10, 0), Vector3.new(0, -100, 0))