Playing a sound on collision?

Posted by Eric McLoughlin on Game Development See other posts from Game Development or by Eric McLoughlin
Published on 2012-04-13T14:12:42Z Indexed on 2012/04/13 17:43 UTC
Read the original article Hit count: 224

Filed under:
|

I'm making a pool game. I've separated the gameplay logic and the physics into two systems, entities and physics. Each entity holds a reference to a body which the physics system uses. The body itself holds a reference back to it's owner. When an entity collides with another entity, the Collided(Entity other) method is called on both.

What I'm trying to do now is to play a sound when both entities colliding are of a certain subclass. I'm not sure how to do that. I could do it in the Collided method, but then the sound would be played two times at the same time, since the method was called on both entities.

How do you suggest I do this?

© Game Development or respective owner

Related posts about physics

Related posts about sound