Problem Using LayerMask - Collisions


I’m having a bit of trouble using LayerMasking for my Physics.Raycast.

I basically want my raycast to only ignore layers 8 and 14, how would I do that?

var layerMask = 8 << 14;
layerMask = ~layerMask;


2 ways:

  1. var layerMask = ~((1<<8)|(1<<14))

(Remember to assign the script to object again , so the value will be updateds)

  1. Declare as var
    layerMask:LayerMask; and you can
    specify it in Inspector.

You can refer to the question I asked before if you want to know more about LayerMask, lol