This project has moved and is read-only. For the latest updates, please go here.

Changing CollisionCategories on the fly

May 4, 2009 at 5:56 PM


I'm developing a side-scrolling platform game with many action planes (depths). For each plane I've reserved a CollisionCategory in order to make collide geoms that are on the same plane but I've found that if a body is not moving changing it's CollisionCategories and CollidesWith properties on the flay has no effect.


- Two geoms (A and B)
- A standing on top of B
- Both having  CollosionCategories=CollisionCategory.Cat1  and  CollidesWith=CollisionCategory.Cat1
- I change A.CollisionCategories and A.CollidesWith to CollisionCategory.Cat2...

But nothing happens... A wont fall from B. Any idea why ? Thanks.

May 4, 2009 at 7:33 PM
This might have some relation to:

The problem might be that the engine does not clean up after itself when properties related to the collision system is changed, while a collision occurs.
I'll test it out and fix it. Thanks for reporting it.
May 4, 2009 at 7:34 PM
@daviddq: I'm pretty sure you need to take your geometries out of collision group 0. That is a special group that causes all geometries in it too always collide. The manual notes this but doesn't specify that you must change the collision group to anything but group 0 to use the categories.
May 4, 2009 at 7:34 PM
Try out Matt's suggestion first and tell us how it goes.
May 4, 2009 at 7:58 PM

Hi again,

Thank you very much for your suggestion. Now every geom is assigned to it's own CollisionGroup (each != 0) but it behaves exactly the same.
May 4, 2009 at 9:51 PM
It was indeed a case of the engine not cleaning up after itself. I've fixed this bug and several other scenarios where it can happen.
The fix is included in change set 49762. You can download it from here:

Thanks again for reporting the bug. Really appreciate it.
May 5, 2009 at 8:59 AM

Thank you very much for your help. As soon as I get home I'll try it and feedback.

Best regards.
May 5, 2009 at 4:47 PM

Hi genbox,

I've applied the fix and now it works fine :)

Thank you very much for your quick help.