Complex physics bodies registering multiple hits. Why???

I have been experimenting with complex multi-shape physics bodies. It’s easy enough to set up in Corona, but in my testing, I’m getting multiple hits returned by the collision detection engine when an object collides with both bodies in a single game cycle (and this can happen more often than you might think!)

Take the example image below as a reference. The red ball falls directly down and collides with the 2-shape body (blue). It hits basically in the center of this blue body, and technically strikes both objects at the same time. This registers TWO hits with the collision engine, even though the blue body is defined as one physical object (just with two body parts).

So I’m wondering if there’s any way to prevent this. Technically, Corona and Box2D aren’t “wrong”… the red ball really IS hitting both blue shapes. But I would like to register the entire blue body as one shape in regards to the collision system. Why? In my game, the red ball striking the blue shape costs the player 1 life point… so in this case, it knocks off 2 life points, which really isn’t correct. Just to clarify again, this blue body is defined as a multi-body physical object, not two separate bodies.

Using the “phase” commands like “phase="began"” does not fix the issue.

I considered setting a flag such as “justCollided=true” and then setting it to “false” in the next game cycle using a Runtime listener, but this seems like a tedious addition to (what should be) a more simple solution. Any other ideas? I could probably re-arrange the 2 bodies in a horizontal orientation, but this won’t solve my problem either… the ball won’t always be falling from above, it might strike the blue shape from any direction, which could lead to these multiple hit registers. Argh! A little frusterating. :stuck_out_tongue:

Brent Sorrentino
Ignis Design
[import]uid: 9747 topic_id: 9502 reply_id: 309502[/import]

Hey
I am having trouble with complex body physics I just can get the collision right
I see that you were able to get yours to register a collision could you take a look
at my post and tell me what I am doing wrong
thanks

http://developer.anscamobile.com/forum/2011/04/30/complex-bodies-collision-and-image-switching [import]uid: 43696 topic_id: 9502 reply_id: 34739[/import]

Don’t you just return true from the collision event listener function to stop the event propogating to other bodies? [import]uid: 8271 topic_id: 9502 reply_id: 34761[/import]

Hi horacebury,

Good suggestion… I actually did not have “return true” at the end of my collision function. However, I added it just now and the result is the same: two hits are still being registered when one object collides with 2 body parts of another object in the same game cycle.
[import]uid: 9747 topic_id: 9502 reply_id: 34770[/import]

@IgnisDesign,

Did you ever get this fixed?

We are having the same problem…

http://developer.anscamobile.com/forum/2011/08/13/issensor-causing-multiple-collisions#comment-51468 [import]uid: 40538 topic_id: 9502 reply_id: 51470[/import]

Sorry for the long reply delay. I think you should post some code snippets… [import]uid: 8271 topic_id: 9502 reply_id: 51733[/import]