Layermasking Issues

Hello,

I’m having some issues with layer masks and just can’t figure out the problem!

So I tried to use multiple-layer masking with bit-shifting but I couldn’t do them to combine properly. They both work as intended if not combined.

Here is the code for the layer masks. I’m using them inside a NonAllocRayCast function.

var THIS_DOESN'T_WORK = (1 << LayerMask.NameToLayer("Default"))
        | (1 << LayerMask.NameToLayer("Hitbox"));

var THIS_WORKS  = (1 << LayerMask.NameToLayer("Default"));
var THIS_WORKS  = (1 << LayerMask.NameToLayer("Hitbox"));

Any help would be appreciated!!

Hi, can you provide some more context, because this should work fine.
https://unity.huh.how/bitmasks