public static bool BoxCast(Vector3 center,
Vector3 halfExtents,
Vector3 direction,
Quaternion orientation = Quaternion.identity,
float maxDistance = Mathf.Infinity,
...);
These are the parameters for a boxcast in Unity3D. I am confused over the purpose of the maxDistance
parameter as we already draw the box with the halfExtents
parameter. What if I don't want to move the box? I.e., I want to draw a box and get information about whatever is inside of it. I am not looking to move the box. Using maxDistance = 0
seems to do nothing as it does not register any hits. Using maxDistance > 0
will move the box, and I am looking to avoid this.
How can I use BoxCast(), avoiding moving the box?
There is Physics.OverlapBox
, perhaps that would better suit your needs?
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
Or maybe even Physics.CheckBox
if you dont care whats actually in the box.
https://docs.unity3d.com/ScriptReference/Physics.CheckBox.html