Question about how boxcast works

About the parameters “halfextents” and “maxdistance”.

If i boxcast on the z axis with center being 0,0,0, and the z axis of half extents is 5, and max distance is 1, where would the edge of the boxcast be?

would it be at 1 z? or 6 z?

- Answer: The Distance that will be checked will be 5+1=6

  • Explanation:

    if ( Physics.BoxCastNonAlloc(
    center: Vector3.zero ,
    halfExtents: new Vector3( 1 , 1 , 6 ) * 0.5f ,
    direction: Vector3.forward ,
    results: hit ,
    orientation: transform.rotation ,
    maxDistance: 1 ) > 0 )
    Debug_float = 1;
    else
    Debug_float = 0;

the code will check halfExtents + maxDistance

in the image Below:

  • white box = halfExtents
  • Red Box = maxDistance
  • the Sphere is the cast results
  • The output: Debug_float = 1