Version: 2021.2

Physics2D.OverlapCapsuleAll

切换到手册
public static Collider2D[] OverlapCapsuleAll (Vector2 point, Vector2 size, CapsuleDirection2D direction, float angle, int layerMask= DefaultRaycastLayers, float minDepth= -Mathf.Infinity, float maxDepth= Mathf.Infinity);

参数

point 胶囊体的中心。
size 胶囊体的大小。
direction 胶囊体的方向。
angle 胶囊体的角度。
layerMask 筛选器,用于检查仅在指定层上的对象。
minDepth 仅包括 Z 坐标(深度)大于该值的对象。
maxDepth 仅包括 Z 坐标(深度)小于该值的对象。

返回

Collider2D[] 返回的投射数量。

描述

Get a list of all Colliders that fall within a capsule area.

This function is similar to OverlapCapsule except that all Colliders that fall within the capsule are returned. The Colliders in the returned array are sorted in order of increasing Z coordinate. An empty array is returned if there are no Colliders within the box.

注意,该函数将为返回的 Collider2D 数组分配内存。如果需要频繁进行检查,可以使用 OverlapCapsuleNonAlloc 来避免这种开销。

另请参阅:OverlapCapsuleOverlapCapsuleNonAlloc