Version: 5.6
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 Vector representing the direction of the circle.
distance Maximum distance over which to cast the circle.
layerMask 特定のレイヤーのコライダーのみを判別するためのフィルター
minDepth この値以上の Z 座標(深度)を持つオブジェクトのみを含みます。
maxDepth この値以下の Z 座標(深度)を持つオブジェクトのみを含みます。

戻り値

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

説明

シーン上のコライダーに円を投げかけ、接触した最初のコライダーを返します。

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 Vector representing the direction of the circle.
contactFilter The contact filter used to filter the results differently, such as by layer mask, Z or depth buffer, 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 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.