Version: 2022.3
言語: 日本語
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. Note: This method will be deprecated in a future build and it is recommended to use BoxCast instead.

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

The returned RaycastHit2D returns both the point and normal of the contact where the box would touch the Collider. It also returns the centroid where the box would be positioned for it to contact at that point.

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