origin | 圆形在 2D 空间中的起点。 |
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.
从概念上说,CircleCast 就像朝特定方向拖动一个圆形穿过场景一样。在该过程中,可以检测并报告与圆形接触的任何对象。
函数返回一个 RaycastHit2D 对象,该对象引用了盒体命中的碰撞体(如果未命中任何对象,则结果的碰撞体属性将为 NULL)。layerMask 可用于仅在特定层上有选择地检测对象(例如,这让您能够仅将检测应用于敌人角色)。
返回的 RaycastHit2D 将返回圆形将与碰撞体接触的点和法线。此外,它还返回当圆形接触该点时圆形的质心。
另请参阅:LayerMask 类、RaycastHit2D 类、CircleCastAll、CircleCastNonAlloc、DefaultRaycastLayers、IgnoreRaycastLayer、raycastsHitTriggers。
origin | 圆形在 2D 空间中的起点。 |
radius | 圆形的半径。 |
direction | A vector representing the direction of the circle. |
contactFilter | 接触筛选器,用于以不同方式筛选结果,例如按层遮罩、Z 深度或法线角度。 |
results | 用于接收结果的数组。该数组的大小决定可返回的结果的最大数量。 |
distance | The maximum distance over which to cast the circle. |
int
返回放置在 results
数组中的结果数。
向场景中的碰撞体投射圆形,返回与圆形接触的所有碰撞体。
从概念上说,CircleCast 就像朝特定方向拖动一个圆形穿过场景一样。在该过程中,可以检测并报告与圆形接触的任何碰撞体。
该函数返回找到的接触点数,并将这些接触点放入 results
数组。也可以通过 contactFilter
对结果进行过滤。
另请参阅:ContactFilter2D 和 RaycastHit2D。
origin | 圆形在 2D 空间中的起点。 |
radius | 圆形的半径。 |
direction | A vector representing the direction of the circle. |
contactFilter | 接触筛选器,用于以不同方式筛选结果,例如按层遮罩、Z 深度或法线角度。 |
results | The list to receive results. |
distance | The 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
.
另请参阅:ContactFilter2D 和 RaycastHit2D。