Am I understanding BoxCast correctly?

I have the following grounding check in my game:

private bool IsGrounded()
    {
        return Physics2D.BoxCast(coll.bounds.center, coll.bounds.size, 0f, Vector2.down, .1f, jumpableGround);
    }

I understand this BoxCast as an invisible box that has the same dimensions as the box collider of this object, but it’s moved down by a tiny bit (the .1f distance argument)
By positioning it like this we can detect if something collides with our object at the bottom, but not on the sides or top.
This is how I visualize it in my head (notice the 2 lines at the bottom of the right image). Is my understanding correct?
7151458--855853--upload_2021-5-18_12-28-56.png

Hi.

You define a shape, and then it is cast forwards. Its shape and path will define a volume that will be used for overlap test. Documentation says this: “A BoxCast is conceptually like dragging a box through the Scene in a particular direction”. So it can be used for detecting a collision. It returns the first hit. Then there is BoxCastAll which returns all the colliders colliding with the volume created by cast box - AFAIK.

Check this video. I remember watching this a while back and it had pretty nice visualization which shows how box cast works:

Thank you. From what I understand it looks like my visualization is correct.

“From what I understand it looks like my visualization is correct.”

Pretty much. Although…

“an invisible box that has the same dimensions as the box collider of this object”

This isn’t exactly true. You can define the size and rotation as you wish, it is not tied to your collider, although you can make it the size of your collider. There is Collider2D.Cast which casts your collider.

A box cast is unnecessary for ground checks with a contact filter setup. Check out this post from @MelvMay that uses a contact filter for an extremely simple ground check that works awesome.

Alright, thank you for your answer everyone!