Dear gaming Gurus... Multiple collisions, single event.

Hi all, imagine you were making a breakout clone, but the bat was made up of two physics bodies (side by side). Everytime your ball hit the bat(s) you posted one point to your score…

I want the bat to behave like a single physics body when it comes to scoring, so my problem arrises when the ball collides with more than one physics body, for example ‘at the join’.

I have an update score event attached to both physics bodies (there’s no other way around it) but I only want to ‘score’ a point per bounce, even if it’s via both bodies at the same time.

I hope I’ve been clear with that, it’s not the easiest thing to describe.

Is there a code snippet anyone’s used in the past? I was thinking of momentarily removing the physics body and then adding it again, but it sounds messy, especially as it’s all happening around a collision event.

Thanks

Hi @Caithan Games,

For clarity, is the “bat” composed of two physics bodies joined together via a joint, i.e. a “weld” joint? Or is it one multi-element physics body?

Brent

You could also just create an invisible physics body that is “pinned” via Runtime listener or other means and have that be the score detection body. 

That’s exactly what I did, thanks.

Hi @Caithan Games,

For clarity, is the “bat” composed of two physics bodies joined together via a joint, i.e. a “weld” joint? Or is it one multi-element physics body?

Brent

You could also just create an invisible physics body that is “pinned” via Runtime listener or other means and have that be the score detection body. 

That’s exactly what I did, thanks.