Alan_s Alan_s - 1 year ago 86
iOS Question

Multiple collision bitmasks on 1 physics object?

Can one physics body have 2 different collision bit masks?

I have this code:

bo.physicsBody?.collisionBitMask = noneCategory


But I'd like "bo" to also collide with "bumperCategory". So, I imagine it could look something like this:

bo.physicsBody?.collisionBitMask = noneCategory && bumperCategory


That doesn't work. Is there anyway to do something similar to this?

Answer Source

You were close, but you need to bitwise OR instead of logical AND the two categories:

bo.physicsBody?.collisionBitMask = noneCategory | bumperCategory
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download