Version: 2020.3
言語: 日本語

Physics2D.GetRayIntersectionNonAlloc

マニュアルに切り替える
public static int GetRayIntersectionNonAlloc (Ray ray, RaycastHit2D[] results, float distance= Mathf.Infinity, int layerMask= DefaultRaycastLayers);

パラメーター

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

戻り値

int 引数の変数に結果が代入されます。

説明

Cast a 3D ray against the Colliders in the Scene returning the Colliders along the ray. Note: This method will be deprecated in a future build and it is recommended to use GetRayIntersection instead.

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

This function is similar to the GetRayIntersectionAll function except that the results are returned in the supplied array. The integer return value is the number of objects that intersect the ray (possibly zero) but the results array will not be resized if it doesn't contain enough elements to report all the results. The significance of this is that no memory is allocated for the results and so garbage collection performance is improved when such calls are performed frequently. The Colliders will be placed in the returned array in order of distance from the start of the ray.

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