CollisionGroups Subgroups can't collide with themselves. #163
-
I was trying to do something similar to the alternate filtering demo but I'm having a hard time... What I want, is boxes that are in a group. Lets call it "Red Group". These boxes should collide with each other like normal. A platform that acts as a safe pass through. Where ONLY red boxes are allowed through. This is like a trapdoor. If I put the Red Group and the trapdoor in the same ColliderGroup the trapdoor functions, however the boxes DONT collide with each other. So what I tried to do, is have the boxes in a subgroup (lets say group 1) and the trapdoor in another subgroup (group 3). I DISABLE collision between subGroup 1 and subGroup 3 so they fall through the trapdoor. I ENABLE collision between subGroup 1 and subGroup 1 so they collide with each other. The Trapdoor works as expected, the boxes fall through. However, the Boxes do not collide with each other no matter what I do. Is there no way to have a subgroup collide with itself? I have a live codesandbox HERE All objects (besides the floor) are using the same CollisionGroup and are set in GroupID 0. The Blue platform is acting as the trapdoor I explained and is in subGroup 3. The Red platform is in the same subgroup as the boxes (subgroup1). The boxes should collide with this layer. The yellow platform is another subGroup but without explicit collision settings. It correctly collides. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
The GroupFilterTable never allows a sub group to collide with the same sub group:
I would use collision layers instead through e.g. the ObjectLayerPairFilterTable, these allow defining if a layer collides with itself or not. Alternatively you can write your own GroupFilter implementation by extending GroupFilterJS and defining the logic in the way you want, something like:
(warning totally untested code) |
Beta Was this translation helpful? Give feedback.
The GroupFilterTable never allows a sub group to collide with the same sub group:
https://github.com/jrouwe/JoltPhysics/blob/cca9c4ad170aff8119632ea8763474f1b20f8d54/Jolt/Physics/Collision/GroupFilterTable.h#L30
I would use collision layers instead through e.g. the ObjectLayerPairFilterTable, these allow defining if a layer collides with itself or not.
Alternatively you can write your own GroupFilter implementation by extending GroupFilterJS and defining the logic in the way you want, something like: