Raycast Mask is used as raydistance.

Raycast mask is mistaken for distance. Can only use the mask if the distance if filled in.

C#

Ignores Mask:

LayerMask mask = 1 << 12;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit = new RaycastHit();
if (Physics.Raycast(ray, out hit,mask))
{
}

Uses Mask:

LayerMask mask = 1 << 12;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit = new RaycastHit();
if (Physics.Raycast(ray, out hit,1000,mask))
{
}

Dont know if its a bug but it was anoying trying to figure out why my mask wasn’t working.

Its not a bug, there just isn’t a function that takes ray, hitinfo and a mask. The closest is the one that takes ray, hitinfo and distance (with mask as an optional parameter) which is why it got used.

Did you check the documentation?