Version: 2018.2
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);

パラメーター

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

戻り値

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

説明

シーンにボックス形状を投げかけ、与えられた results 配列にコライダーを返します。

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

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

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

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961