Version: 2020.1
言語: 日本語
public static RaycastHit2D CircleCast (Vector2 origin, float radius, Vector2 direction, float distance= Mathf.Infinity, int layerMask= DefaultRaycastLayers, float minDepth= -Mathf.Infinity, float maxDepth= Mathf.Infinity);

パラメーター

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

戻り値

RaycastHit2D 投げかけた結果が返されます。

説明

Casts a circle against colliders in the Scene, returning the first collider to contact with it.

A CircleCast is conceptually like dragging a circle through the Scene in a particular direction. Any object making contact with the circle can be detected and reported.

この関数は RaycastHit2D オブジェクトと、ボックスに接触したコライダーに対する参照を返します(コライダープロパティーは、何も接触していない場合は null を返します)。layerMask により、特定のレイヤーのオブジェクトのみを選択的に検出することができます。(これにより、例えば敵キャラクターのみを検出するということなどができます)

返される RaycastHit2D は円形がコライダーに触れる場所の点と法線両方の情報を持ちます。また、その点に接触するために円が位置するであろう重心も返します。

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


public static int CircleCast (Vector2 origin, float radius, Vector2 direction, ContactFilter2D contactFilter, RaycastHit2D[] results, float distance= Mathf.Infinity);

パラメーター

origin The point in 2D space where the circle originates.
radius 円の半径
direction A vector representing the direction of the circle.
contactFilter The contact filter used to filter the results differently, such as by layer mask, Z depth, or normal angle.
results The array to receive results. The size of the array determines the maximum number of results that can be returned.
distance The maximum distance over which to cast the circle.

戻り値

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

説明

Casts a circle against colliders in the Scene, returning all colliders that contact with it.

A CircleCast is conceptually like dragging a circle through the Scene in a particular direction. Any collider making contact with the circle can be detected and reported.

This function returns the number of contacts found and places those contacts in the results array. The results can also be filtered by the contactFilter.

See Also: ContactFilter2D and RaycastHit2D.


public static int CircleCast (Vector2 origin, float radius, Vector2 direction, ContactFilter2D contactFilter, List<RaycastHit2D> results, float distance= Mathf.Infinity);

パラメーター

origin The point in 2D space where the circle originates.
radius 円の半径
direction A vector representing the direction of the circle.
contactFilter The contact filter used to filter the results differently, such as by layer mask, Z depth, or normal angle.
results The list to receive results.
distance The maximum distance over which to cast the circle.

戻り値

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

説明

Casts a circle against Colliders in the Scene, returning all Colliders that contact with it.

A CircleCast is conceptually like dragging a circle through the Scene in a particular direction. Any Collider making contact with the circle can be detected and reported.

The integer return value is the number of results written into the results list. The results list will be resized if it doesn't contain enough elements to report all the results. This prevents memory from being allocated for results when the results list does not need to be resized, and improves garbage collection performance when the query is performed frequently.

The results can also be filtered by the contactFilter.

See Also: ContactFilter2D and RaycastHit2D.

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