Skip to main content

Collider.Raycast(Ray ray, number maxDistance)

Casts a Ray that ignores all Colliders except this one.

Parameters:

NameTypeDescription
rayRayThe starting point and direction of the ray.
maxDistancenumberThe max length of the ray.

Returns:

typeDescription
booleanTrue when the ray intersects the collider, otherwise false.
RaycastHitIf true is returned, hitInfo will contain more information about where the collider was hit.

Usage

---@type Collider
local collider;

---@type Ray
local ray;

---@type number
local maxDistance;


local val0, val1 = collider.Raycast(ray, maxDistance)

Example

local didHit, hitInfo = someCollider.Raycast(Ray(Vector3.zero, Vector3.forward), 50);