| start | 胶囊start位置处的球体的中心。 |
| end | 胶囊end位置处的球体的中心。 |
| radius | 胶囊的半径。 |
| layermask | 一个层遮罩,用于在投射胶囊时有选择地忽略碰撞器。 |
| queryTriggerInteraction | 指定此查询是否应击中触发器。 |
检查世界空间中是否有任何碰撞器与胶囊形状的体积重叠。
胶囊由围绕point1和point2的radius半径的两个球体定义,这两个球体形成胶囊的两端。
using UnityEngine;
public class Example : MonoBehaviour { // Given the start and end waypoints of a corridor, check if there is enough // room for an object of a certain width to pass through. bool CorridorIsWideEnough(Vector3 startPt, Vector3 endPt, float width) { return Physics.CheckCapsule(startPt, endPt, width); } }