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

パラメーター

originThe point in 2D space where the circle originates.
radius円の半径
directionA vector representing the direction of the circle.
distanceThe 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);

パラメーター

originThe point in 2D space where the circle originates.
radius円の半径
directionA vector representing the direction of the circle.
contactFilterThe contact filter used to filter the results differently, such as by layer mask, Z depth, or normal angle.
resultsThe array to receive results. The size of the array determines the maximum number of results that can be returned.
distanceThe 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.


パラメーター

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

戻り値

void 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.