Skip to content

format

typescript
Physics.RaycastAll(ray, maxDistance, mask, cast_trigger)

class: Physics

description

Performs a raycast and returns all the hit objects.

This method shoots a virtual ray in the scene to check if it intersects with any objects, and stores the intersection information with all the objects.

parameter

param_nametypedescription
rayRayThe ray object to be shot.
maxDistancenumberThe maximum distance the ray can be cast.
masknumberThe layers to perform collision detection on (bitwise operation).
cast_triggerQueryTriggerInteraction?Whether the ray should perform collision detection with triggers.

return

typedescription
RaycastHit|undefinedWhether the ray intersects with any objects. If there is no intersection, undefined is returned.

code example