public static bool CheckCapsule (Vector3 start, Vector3 end, float radius, int layerMask= DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction= QueryTriggerInteraction.UseGlobal);

参数

start胶囊体在 start 处的球体中心。
end胶囊体在 end 处的球体中心。
radius胶囊体的半径。
layermask 层遮罩,用于在投射胶囊体时有选择地忽略碰撞体。
queryTriggerInteraction指定该查询是否应该命中触发器。

描述

检查是否有任何碰撞体与世界空间中的胶囊形体积重叠。

胶囊体由中心位于 point1radius、半径为 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); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961