Collision group groups


I have been working on a game for a reasonable amount of time now, and one thing I think would greatly improve the engine is some kind of group for groups in the collisionobjects. For example, I have many maps in my game. Each has a collisionobject set to the tilemap for the map. However, if I want to add a new group which collides with all the map geometry, I have to go through every single map and add that group to the collisionobject. If I forget one, then things seem like they’re working until I play that map and then the missing group becomes apparent. Better would be to have a group such as “map colliding groups” and then list all the collision groups that should collide with maps. Then, the maps could have a mask for the “map colliding group” which when compiled could expand out to the list of groups that maps should collide with. This would save a ton of time going forward as I add more content to the game.



What’s the reasoning for adding unique collision group ids based on the map? Maybe there is a better way to tag the enemies of each unique map?



Each enemy uses the “enemy” group in my game, but I have other groups that should collide with the level collisionobject. For example, right now my mask for the level looks like this: “default, items, player, enemy, projectile, breakable” However, if I were to add another group which collides with levels, then I must change this for all the levels instead of just having a group for groups used for all levels. In the case of when I added breakable objects, I had to modify all my levels to include “breakable”. I’m thinking I will add an “explosion” group perhaps eventually to handle explosions which I don’t want to pass through walls. These may interact in different ways than a projectile (since I’m using triggers for these.) However, I have ~20 maps already. So this requires updating 20 collisionobjects to include the new group.



Another option would be to add the possibility to edit the collision groups at runtime (not currently possible as far as I know?). Then you could build your own logic around it. I don’t think Box2D supports “groups groups”, so may be a more clean approach.




Go and vote!



Runtime edits would be great, i think. Voted.

Having collision group groups, i think would not be worth implementing. Unless something has changed, I believe the max collision groups is still 16? I feel like a basic game design doc before starting to jump into adding groups and masks to objects basically solves this issue, at least for me.

Personally, since i almost never use dynamic collision objects, I tend to make very few groups (geometry, entity, item, player, maybe another 1 or 2), and use (if everything has a script attached) or a lua module of GOs w/ my own “sub-groupings” to compare against for handling kinematic collisions.

I have no idea if this is a “good” solution, or what kind of overhead it adds, but i ran hard into the 16 group limit a few years ago working on a jam game with much-too-granular collision groupings, and vowed never to rely on that again if I can get away with it.