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

Having OnSeparation get called when the body/geom is removed.

Topics: User Forum
Mar 31, 2010 at 4:26 PM

I am relying on OnSeparation to get called when I remove bodies from the world, but they do not seem to fire OnSeparation.

Can anyone confirm that if two bodies are colliding, and one gets removed, the OnSeparation event gets fired?


Thanks! =)

Mar 31, 2010 at 7:58 PM

From looking at 3.0, the OnSeparation delegate is fired

when two Fixtures (or Geoms) are touching each other one frame, and not the next.


When you dispose Fixtures (or Geoms), then they don't exist anymore, and so the

missing entities cannot be evaluated.


You may have to first force the fixture or geom to not touch using a number of

different tricks (perhaps ignoreCollisionWith? maybe not), then force a physics

pass to activate the OnSeparation, then dispose the bodies you want.


To be honest, from the sounds of it, the best thing for you to do is to dispose

your bodies you want to in your OnSeparation delegate that is fire from, again,

using a number of tricks.





Mar 31, 2010 at 9:55 PM

Thanks.  That's exactly what I tried, and it works great.

Basically, when I want to remove the body, i set the bodies' position far off into no where, which fires the OnSeparation.  The next update, i disable the body.  Works great :)