direction | 図形を投影する方向を表すベクトル |
results | 結果を受け取る配列 |
distance | 図形を投影する最大距離 |
ignoreSiblingColliders | 同じ Rigidbody2D にアタッチされているコライダーを無視するかどうか |
int 引数の変数に結果が代入されます。
Casts the collider shape into the Scene starting at the collider position ignoring the collider itself.
This function will take the collider shape and cast it into the Scene starting at the collider position in the specified direction
for an optional distance
and return the results in the provided results
array. The integer return value is the number of results written into the results
array. 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 casts are performed frequently.
それに加えて、この関数は重なっている場合に Ray の始点にある他のコライダーも検知し、 Ray の始点はコライダー内部で、コライダーの表面と交差しません。これは衝突判定の法線が Ray のベクトルを逆に設定する場合、衝突判定の法線が計算できないという意味です。この問題が起こった場合、 RaycastHit2D が0になるため簡単に検知できます。
Note: Use of Collider2D.Cast() requires the use of Rigidbody2D. If
no Rigidbody2D is declared Cast() does not work. However a Rigidbody2D
can be static and attached to the Collider2D. This will make the Cast() work as
expected. Also, if the Collider2D object has no Rigidbody2D object
then it can collide with objects which have both Collider2D and Rigidbody2D
objects.
direction | 図形を投影する方向を表すベクトル |
contactFilter | Filter results defined by the contact filter. |
results | 結果を受け取る配列 |
distance | 図形を投影する最大距離 |
ignoreSiblingColliders | 同じ Rigidbody2D にアタッチされているコライダーを無視するかどうか |
int 引数の変数に結果が代入されます。
Casts the collider shape into the Scene starting at the collider position ignoring the collider itself.
This function will take the collider shape and cast it into the Scene starting at the collider position in the specified direction
for an optional distance
and return the results in the provided results
array. The integer return value is the number of results written into the results
array. 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 casts are performed frequently.
The contactFilter
parameter, can filter the returned results by the options in ContactFilter2D.
それに加えて、この関数は重なっている場合に Ray の始点にある他のコライダーも検知し、 Ray の始点はコライダー内部で、コライダーの表面と交差しません。これは衝突判定の法線が Ray のベクトルを逆に設定する場合、衝突判定の法線が計算できないという意味です。この問題が起こった場合、 RaycastHit2D が0になるため簡単に検知できます。