-
-
Notifications
You must be signed in to change notification settings - Fork 4
Category and Mask Bits
selimanac edited this page Oct 8, 2024
·
3 revisions
Mask bits for collision filtering work the same way as Group and Mask in Defold. They only operate within a single group.
Although categories are limited to 64 bits, I strongly recommend staying within 32 bits due to potential platform differences.
Each category should be a unique power of two, ensuring clear and non-overlapping bitwise representations. More bitwise operations available on Defold API docs.
local collision_bits = {
PLAYER = 1,
ENEMY = 2,
GROUND = 4,
ITEM = 8,
TRIGGER = 16,
WALL = 32,
PLATFORM = 64,
PROJECTILE = 128,
NPC = 256,
ENVIRONMENT = 512,
ALL = bit.bnot(0) -- -1 for all results
}
-- Mask bits to use with queries
local mask_bits = bit.bor(collision_bits.ENEMY, collision_bits.ITEM)
If you find my Defold Extensions useful for your projects, please consider supporting it.
I'd love to hear about your projects! Please share your released projects that use my native extensions. It would be very motivating for me.