How can I set collision layers or masks with the bit format?

Godot Version

4.2

Question

image

I am mimicking a z axis in a top down 2d game using many collision layers. I noticed that the layers have assigned bits, but the only method to set them I could find is to manually set each one with a new line of code. Is there some way I can use the bit number instead so I can set all of them to false or true in one line?

Just set the collision_mask property to an int that packs the right binary mask.

i.e. collision_mask = 233

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.