Version: 2022.3
public bool CapsuleCast (Vector3 point1, Vector3 point2, float radius, Vector3 direction, out RaycastHit hitInfo, float maxDistance= Mathf.Infinity, int layerMask= DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction= QueryTriggerInteraction.UseGlobal);

参数

point1 胶囊体在 start 处的球体中心。
point2 胶囊体在 end 处的球体中心。
radius 胶囊体的半径。
direction 扫描胶囊体的方向。
hitInfo 如果返回 true,则 hitInfo 将包含有关碰撞体的撞击位置的更多信息(另请参阅:RaycastHit)。
maxDistance 扫描的最大长度。
layerMask 层遮罩,用于在投射胶囊体时有选择地忽略碰撞体。
queryTriggerInteraction 指定该查询是否应该命中触发器。

返回

bool 当胶囊体扫描与任何碰撞体交叠时为 true,否则为 false。

描述

向物理场景中的所有碰撞体投射胶囊体,并返回有关命中对象的详细信息。

另请参阅:Physics.CapsuleCast


public int CapsuleCast (Vector3 point1, Vector3 point2, float radius, Vector3 direction, RaycastHit[] results, float maxDistance= Mathf.Infinity, int layerMask= DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction= QueryTriggerInteraction.UseGlobal);

参数

point1 胶囊体在 start 处的球体中心。
point2 胶囊体在 end 处的球体中心。
radius 胶囊体的半径。
direction 扫描胶囊体的方向。
results 用于存储结果的缓冲区。
maxDistance 扫描的最大长度。
layerMask 层遮罩,用于在投射胶囊体时有选择地忽略碰撞体。
queryTriggerInteraction 指定该查询是否应该命中触发器。

返回

int 存储到 results 缓冲区的命中对象数量。

描述

向物理场景中的所有碰撞体投射胶囊体,并返回有关命中对象的详细信息。

另请参阅:Physics.CapsuleCastNonAlloc