GetRayIntersectionAll(Ray, float, int)
Cast a 3D ray against the 2D Colliders in the Scene.
Read time 1 minuteLast updated 6 days ago
Definition
- Type: Method
- Namespace: UnityEngine
- Assembly: UnityEngine.Physics2DModule
public static RaycastHit2D[] GetRayIntersectionAll(Ray ray, float distance, int layerMask = -5)
Parameters
Returns
Type | Description |
|---|---|
| RaycastHit2D[] | The ray intersection results. |
Remarks
This function acts as a 3D "ray cast" but specifically designed to detect 2D Colliders. It achieved this by projecting the 3D ray into 2D space and then performs the 2D intersection test, ordering the results by the Z direction of the original 3D ray.
NOTE: All results are sorted into ascending distance order i.e. the first result is the closest.