Hi there,

I set up doors with different NAvNesh layers, but I can’t find a match between the layer index and the value of the walkableMask.

So my question is what is the value of the walkableMask parameter referencing to ? Is it a layer number ? but there are Built in layers and user layers.

For example in the user layer 1 I have setup door 1 and user layer 2 contains door2
How do I activate / deactivate them in runtime?

Thank you
Yaniv

Jean from the Playmaker forum answered this in depth:
http://hutonggames.com/playmakerforum/index.php?topic=5280.msg25225#msg25225

OK; let’s do some binary maths!!!

Binary is a very powerful thing, you only have 0 and 1, and as you read a long binary number you need to think this way, lets’ take an example

– read the binary from right to left, each binary entry being indexes (n) with its integer equivalent being 2^n, n starting at 0, so the first slot on the right is indexed 0, not 1.

binary slots : x | x | x | x
integer value: 8 | 4 | 2 | 1

so:
100 binary mean 4 as int (4+0+0)
101 means 5 (4+0+1)

Hopefully that make sense. So to translate this to the navmesh layers in Unity

nothing - 0
everything -1
layer 0 - 1 ( built in layer 0)
layer 1 - 2 ( built in layer 1)
layer 2 - 4 ( built in layer 2)
layer 3 - 8 ( user layer 0)
layer 4 - 16 ( user layer 1)
layer 5 - 32 ( user layer 2)
layer 6 - 64 ( user layer 3)
layer 7 - 128 ( user layer 4)

so,
– if you want to only have layer 3 ( user layer 0), the mask is 8, in binary, we would write 1000
– if you want layer 3 AND layer 0, the mask is 8+1=9, in binary: 1001

to find out from the mask integer what layers are defined, it’s bit a more complicated if you are not using binary math operators:
so we have 9: