public static bool BoxCast(Vector3 center,
Vector3 halfExtents,
Vector3 direction,
Quaternion orientation = Quaternion.identity,
float maxDistance = Mathf.Infinity,
...);
这些是 Unity3D 中 boxcast 的参数。我对 maxDistance
参数的用途感到困惑,因为我们已经使用 halfExtents
参数绘制了框。如果我不想移动盒子怎么办?即,我想画一个盒子并获取有关其中任何内容的信息。我不想移动盒子。使用 maxDistance = 0
似乎什么都不做,因为它没有记录任何命中。使用 maxDistance > 0
将移动框,我希望避免这种情况。
如何使用 BoxCast(),避免移动盒子?
最佳答案
有 Physics.OverlapBox
,也许它更适合您的需求?
public static Collider[] OverlapBox(Vector3 center, Vector3 halfExtents,
Quaternion orientation = Quaternion.identity,
int layerMask = AllLayers,
QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal);
https://docs.unity3d.com/ScriptReference/Physics.OverlapBox.html
如果您不关心盒子里的实际情况,甚至可以是 Physics.CheckBox
。
https://docs.unity3d.com/ScriptReference/Physics.CheckBox.html
关于c# - 如何在不移动盒子的情况下进行 BoxCast()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51921502/