Version: 2022.3
言語: 日本語
public static RaycastHit2D[] GetRayIntersectionAll (Ray ray, float distance= Mathf.Infinity, int layerMask= DefaultRaycastLayers);

パラメーター

ray テストすべき Ray を定義づける原点と方向
distance The maximum distance over which to cast the ray.
layerMask 特定のレイヤーのコライダーのみを判別するためのフィルター

戻り値

RaycastHit2D[] 投げかけた結果が返されます。

説明

Cast a 3D ray against the Colliders in the Scene returning all the Colliders along the ray.

This is useful for finding Colliders intersecting an arbitrary 3D ray.

この関数は返された RaycastHit2D 配列にメモリ割り当てを行ないます。GetRayIntersectionNonAlloc を使用して、そのようなコールを頻繁に行なう必要があればこのオーバーヘッドを回避できます。

さらにこの関数は 3D 交差テストであるため RaycastHit2D で返された任意の衝突の法線は 0 となります。