Version: 2022.3
言語: 日本語
public static RaycastHit2D GetRayIntersection (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 the first Collider along the ray.

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

この関数は返された RaycastHit2D オブジェクトに対してメモリを割り当てます。この関数を何度も呼び出すことによるオーバーヘッドを避けるには GetRayIntersectionNonAlloc を使用してください。

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