Physics2d.Raycast only returning hits from Default layer

Hi,
I have an enemy class that moves in straight lines, and does a raycast check before moving to make sure it’s safe. I am finding that I’m only getting collisions back from objects on the default layer.

I haven’t exhaustively tested every case, but I’m definitely not getting collisions from the blocking objects I have set to prevent characters going out of level. Here’s the raycast code:

    RaycastHit2D hit = CheckForCollisions(travelDir);

    RaycastHit2D CheckForCollisions(Vector3 dir)
    {
        RaycastHit2D coll = Physics2D.Raycast(transform.position, dir, 100f, 15);
        return coll;
    }

A length of 100 should easily reach out of the level area. I’m using 15 as the mask, since that’s the layer the character itself is on. The blocker objects are on layer 10. They have BoxCollider2d’s set up, and they will return if I change their layer to default.

I also went into the project Physics2D settings and unchecked everything from “Ignore Raycast.” Still no luck.

Any idea what’s going on?

Ok I’m a dummy who doesn’t read documentation. Figured it out. I assumed the layermask field just took a single int for what you want to mask out. Turns out the truth is more complicated than that -