How to perform collision test

Hey !

I’m failing at understanding how collision masks work. I’ve been trying to optimize some collision tests by matching only a set of elements. This is how the node path are arranged:


  • base-node1
    – target for collision test
    – other node that I don’t care about
  • base-node2
    – target for collision test
    – other node that I don’t care about

The collision traverse traverses the render node. The base-nodes are empty: they don’t contain any collision targets.

  • If the collision mask is set on base-node1 and base-node2, then the collision will successfully be checked on the target nodes. But collisions will also be checked with the “other node that I don’t care about”.
  • If the collision mask is set only on the targets, then no collisions are registered.

Is this the normal behaviour ?
If it is, then what am I supposed to do if I want to only check collisions on the target ? I figured that’s what CollideMasks were for…

EDIT: I know what I’ve done wrong. But then I’m a little puzzled at how collide mask propagate.
What puzzles me is that when we reparent node, the collide mask are combined in a OR-like operation, but when I set a collide mask to a parent, then the children collide masks are completely forgotten and replaced by the parent’s one.
I believed that the order in which we set the collide mask had no importance, and only on which node they were applied on in the hierarchy mattered. It doesn’t, the order matters too.