Download

Playing sound once for multiple simultaneous collisions

I have a impact sound to play when an overlap event happens. It works for one overlap event but if there are multiple overlapping events at the same time the sound will play for each one at the same time. Do I need to use a do once to stop this or is there a better alternative?
Example is a box collider in front of the player that turns on/off when the player attacks. If there is an enemy within the box it plays the impact sound. If there are multiple enemies it plays multiple impact sounds.

You can do a couple of things:

  1. DoOnce, and reset it when the sound’s finished.

  2. Play the sound with a sound cue, you can limit the sound cue to have a maximum of 1 voice.

I am using the do once with a reset when the animation is finished playing. It works but I wanted to be sure it was best practice to do this way.

1 or 2 is fine, there’s probably other ways of doing it.

Personally, I use do once :slight_smile: