Raycast2D detecting originating collider - not wanted

I have a RaycastHit2D that is detecting the object I want it to ignore. I’m trying to find any objects under the originating objects location. How do I ignore the object the raycast started in? I cannot use layer masks or ignore the object because the object below it is of the same class.

        Collider2D cldr = gamePiece.GetComponent<Collider2D> ();
        RaycastHit2D hit = Physics2D.Raycast (cldr.transform.position, Vector2.down, 1f);

In Project Settings > Physics2D, try unchecking the box that says “Raycasts Start In Collider”.

1 Like

Worked like a charm, thanks jester. I’m seeing “Queries start in collider” not “Raycasts start in collider” FYI, works nonetheless.

1 Like

Great! Just out of curiosity: Which version of Unity are you using?

5.2.2f

1 Like

Yes, it was renamed to ‘Queries’ instead of ‘Raycasts’ as it affects all physics queries like line-cast etc.