Version: 2020.1
言語: 日本語
public static int BoxCastNonAlloc (Vector2 origin, Vector2 size, float angle, Vector2 direction, RaycastHit2D[] results, float distance= Mathf.Infinity, int layerMask= DefaultRaycastLayers, float minDepth= -Mathf.Infinity, float maxDepth= Mathf.Infinity);

パラメーター

origin The point in 2D space where the box originates.
size The size of the box.
angle The angle of the box (in degrees).
direction A vector representing the direction of the box.
results 結果を受け取る配列
distance The maximum distance over which to cast the box.
layerMask 特定のレイヤーのコライダーのみを判別するためのフィルター
minDepth この値以上の Z 座標(深度)を持つオブジェクトのみを含みます。
maxDepth この値以下の Z 座標(深度)を持つオブジェクトのみを含みます。

戻り値

int Returns the number of results placed in the results array.

説明

Casts a box into the Scene, returning colliders that contact with it into the provided results array.

この関数は結果が配列に返されること以外は BoxCastAll 関数と同様です。返される int 値は円形と交わるオブジェクトの数です( 0 の可能性もあります)が、オブジェクトの数が配列よりも多くとも配列の長さが変わることはありません。この仕様について重要なのは、この結果からメモリ割り当てが行われないため、頻繁に実行された場合にガベージコレクションのパフォーマンスが向上するということです。

返された RaycastHit2D はボックスがコライダーに触れる接点の座標と法線の両方を返します。また、その時点でボックスが接触するために位置している場所の重心も返します。

関連項目: LayerMask クラス、RaycastHit2D クラス、BoxCastBoxCastAll、、DefaultRaycastLayersIgnoreRaycastLayerraycastsHitTriggers.