does anyone know whether bodies only collide when (body1.categoryBits & body2.maskBits) && (body1.maskBits & body2.categoryBits) ? or do they already collid
This is the way I've understood how maskBits and categoryBits work. Let's say you have 3 objects : objectA, objectB and objectC.
Define for each object a category :
objectA.categoryBits = 0x0002;
objectB.categoryBits = 0x0004;
objectC.categoryBits = 0x0008;
Then, set the maskBits, which define the collisions rules for each categoryBits :
-> objectA collide with everyone (0xFFFF) and (&) not(~) objectB (0x0004)
objectA.maskBits = 0xFFFF & ~0x0004;
-> objectB collide with objectA (0x0002) or (|) objectC (0x0008) but no one else
objectB.maskBits = 0x0002 | 0x0008;
-> objectC collide with objectA (0x0002) but no one else
objectC.maskBits = 0x0002;
I don't know if this is correct, but it worked for me.
HTH