#Need some help with raycast hitting layermask

1 messages · Page 1 of 1 (latest)

quiet citrus
#

Hi! Would like to ask for some help. I am trying to get a raycast to hit the layermask called "whatIsWall" but for some reason it never seems to detect it / the if statement conditions to compare the layermask is wrong. Could someone take a look for me to see what I did wrong?

            bool raycastHit = Physics.Raycast(playerCam.position, playerCam.forward, out RaycastHit firstHit, 2f, whatIsWall);
            if (raycastHit && (whatIsWall.value & 1 << firstHit.collider.gameObject.layer) != 0)```
pliant forum
#

You can also serialize the mask for easier control