Version: 2019.3
public static RaycastHit2D GetRayIntersection (Ray ray, float distance= Mathf.Infinity, int layerMask= DefaultRaycastLayers);

パラメーター

rayテストすべき Ray を定義づける原点と方向
distanceThe 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.

これは任意の 3D の Raycast と交差するコライダーを見つけるのに役に立ちます。

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

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