Skip to main content

CapsuleCollider.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 CapsuleCollider
local capsulecollider;

---@type Ray
local ray;

---@type number
local maxDistance;


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

Example

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