BoxCast: Ignore Collisions with certain layers?


i know it is possible to ignore collisions with raycasts.
However i cannot find a solution for how to ignore collisions between my boxcast and certain layers.

In my case i have a plane that is surrounded by walls.
I am casting several boxcasts on top of the plane that are supposed to tell me what they are hitting.

My problem is that close to the walls i simply get the collision with the wall, as they are obviously colliding, but i want to make it so that the wall is “invisible” for my box cast.

Is there a solution for that?


Looks like it works just like it does with Raycast using LayerMask.

using UnityEngine;

public class MyScript : MonoBehaviour
    public LayerMask myMask;

	void Update ()
        if (Physics.BoxCast(transform.position,, Vector3.down, Quaternion.identity, 100f, myMask))