I have two bodies of type compound polygon.
When they collide , the OnCollision event is raised multiple times for each fixture that makes contact.
I want to negate the x component of linear velocity on collision in this event handler.
However , whenever even number of fixtures collide , linear velocity remains unchanged.
I am also removing bodies associated with my bullets whenever it hits any target.
However,due to multiple fixtures raising OnCollision event for same Collision , code tries to remove bodies which have already been removed.
How do i prevent further fixtures belonging to same body from raising OnCollision event after
first fixture has already raised this event?
Please help !!
Also , please explain the behaviour of DeepCopy on body. I tried to create a deep copy and it did not deep copy fixtures associated with this body leaving the same fixture references on cloned bodies. As FixtureList property is read only for a body , i can't
even set it by manually cloning fixtures as well. How to get around with this?
Thanks and Regards,
Jul 25, 2013 at 10:33 PM
A body does not know about collisions, but fixtures do. I added OnCollision to Body since it can contain multiple fixtures, and when each fixture report back a collision, it will get reported to the body. Imagine a situation where a body with multiple
fixtures hit 2 different things at the same time - if it only reported one of the collisions, it would cause problems too.
If you only need 1 collision, you simply keep track of when a collision happened, and then ignore all other collisions on the body until the next timestep.
DeepCopy is supposed to make a complete copy of the body, as well as all the fixtures and shapes. However, the code was released prematurely and as a result, it is not really usable. I am currently working (as in, right now) on that part of the engine as well