Version: 2020.1
public bool BoxCast (Vector3 center, Vector3 halfExtents, Vector3 direction, out RaycastHit hitInfo, Quaternion orientation= Quaternion.identity, float maxDistance= Mathf.Infinity, int layerMask= DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction= QueryTriggerInteraction.UseGlobal);

参数

center 盒体的中心。
halfExtents 盒体各个维度大小的一半。
direction 投射盒体的方向。
hitInfo 如果返回 true,则 hitInfo 将包含有关碰撞体的撞击位置的更多信息(另请参阅:RaycastHit)。
orientation 盒体的旋转。
maxDistance 投射的最大长度。
layerMask 层遮罩,用于在投射胶囊体时有选择地忽略碰撞体。
queryTriggerInteraction 指定该查询是否应该命中触发器。

返回

bool 如果发现任何交叉点,则返回 true。

描述

沿射线投射盒体并返回有关命中对象的详细信息。

另请参阅:Physics.BoxCast


public int BoxCast (Vector3 center, Vector3 halfExtents, Vector3 direction, RaycastHit[] results, Quaternion orientation= Quaternion.identity, float maxDistance= Mathf.Infinity, int layerMask= DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction= QueryTriggerInteraction.UseGlobal);

参数

center 盒体的中心。
halfExtents 盒体各个维度大小的一半。
direction 投射盒体的方向。
results 用于存储结果的缓冲区。
orientation 盒体的旋转。
maxDistance 投射的最大长度。
layerMask 层遮罩,用于在投射胶囊体时有选择地忽略碰撞体。
queryTriggerInteraction 指定该查询是否应该命中触发器。

返回

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

描述

沿射线投射盒体并返回有关命中对象的详细信息。

另请参阅:Physics.BoxCastNonAlloc