Player can jump on walls with tilemap colliders.

When I go up against a wall in my level which is a tilemap, I can jump on the wall. The tilemap has a composite collider and the player has a box collider. Jumping works fine on walls with box colliders.

Code to check if grounded:

    public bool IsGrounded() {
        float extraHeightTest = 0.01f;
        RaycastHit2D raycastHit = Physics2D.BoxCast(bc2D.bounds.center, bc2D.bounds.size, 0f, Vector2.down,extraHeightTest + extraHeightTest, collisionLayerMask);
        Color rayColor;
        if (raycastHit.collider != null) {
            rayColor = Color.green;
        } else {
            rayColor = Color.red;
        }
        Debug.DrawRay(bc2D.bounds.center + new Vector3(bc2D.bounds.extents.x, 0), Vector2.down * (bc2D.bounds.extents.y + extraHeightTest), rayColor);
        Debug.DrawRay(bc2D.bounds.center - new Vector3(bc2D.bounds.extents.x, 0), Vector2.down * (bc2D.bounds.extents.y + extraHeightTest), rayColor);
        return raycastHit.collider != null;
    }

You dont really explain the issue, but if i had to guess, you dont want the player to be able to jump on walls?

There are many ways to do this, but id say the easiest is to change the layer of the walls.

Change the layer/tag (it looks like you are comparing layer in your raycast) on the walls to something that is not the same as the floor and will not be checked by the raycast for IsGrounded.

You can also add a physics material 2D and change the friction of it to 0. Then apply that physics material to the wall objects (their collider or rigidbody component, i believe). This will prevent the player from getting “stuck” on the wall due to friction.

Correct, I don’t want the player to jump on the walls. The problem is that every ground tile and wall tile are in the same tilemap, which has a composite collider. Meaning I can’t change the layer of individual “walls”. It looks like the issue is with the box cast, because when I use the gizmo button, the draw rays are green when against a wall while mid air.