Ray
Represents a line in 3D space extending indefinitely from a source point (origin) in a specified direction. It is utilized extensively for ray casting and collision detection. Unity's Ray Documentation
Properties
Depicts the path along which the ray extends in 3D space. The direction vector is normalized to have a magnitude of 1. Unity's Ray.direction Documentation
local origin = Vector3.new(0, 0, 0)
local direction = Vector3.new(0, 0, 1)
local ray = Ray.new(origin, direction)
print(ray.direction) -- (0, 0, 1)
Represents the starting point of the ray in 3D space. Unity's Ray.origin Documentation
local origin = Vector3.new(0, 0, 0)
local direction = Vector3.new(0, 0, 1)
local ray = Ray.new(origin, direction)
print(ray.origin) -- (0, 0, 0)
Methods
Retrieves a point along the ray at a specified distance from the origin. The distance is measured in the direction of the ray. Unity's Ray.GetPoint Documentation
local origin = Vector3.new(0, 0, 0)
local direction = Vector3.new(0, 0, 1)
local ray = Ray.new(origin, direction)
local point = ray:GetPoint(5)
print(point) -- (0, 0, 5)
Parameters
distance
The distance along the ray from the origin point.
Returns
Returns the point at the given distance along the ray.
Updated 12 days ago