Changing CollisionCategories on the fly

May 4, 2009 at 4:56 PM

Hi,

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.

Example:

- 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.

Coordinator
May 4, 2009 at 6:33 PM
This might have some relation to: http://farseerphysics.codeplex.com/Thread/View.aspx?ThreadId=55203

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.
Developer
May 4, 2009 at 6: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.
Coordinator
May 4, 2009 at 6:34 PM
Try out Matt's suggestion first and tell us how it goes.
May 4, 2009 at 6: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.
Coordinator
May 4, 2009 at 8: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: http://farseerphysics.codeplex.com/SourceControl/ListDownloadableCommits.aspx

Thanks again for reporting the bug. Really appreciate it.
May 5, 2009 at 7: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 3:47 PM

Hi genbox,

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

Thank you very much for your quick help.