- Home /
Best way to play many audio clips at the same time?
In my game, I have many enemies that die in quick succession. As a result, many death sounds play in quick succession. There seems to be a problem whereby Unity can't handle more than ~10-15 sounds playing at the same time. I have tried the following to fix this:
Create an AudioHandler class whereby each time a sound is played, a new AudioSource is instantiated as a component on the AudioHandler object, and a clip is played on that source before being deleted. I did this thinking that it was a single source getting overloaded, and that if I created multiple sources, it would work, but to no avail.
Still, I can only kill ~10 enemies before the sound overloads and goes silent for ~3 seconds. Does anybody know of a way to have death sounds play for every death?
Thank you!
Quick question before I answer. Are you using playSingleShot(Clip, Volume)? In my game, I use this on a single audio source and can have, or at least I can hear, 20+ sound clips playing from the source.
Hi there -- yes, I am using PlayOneShot(); I am not familiar with PlaySingleShot... I am assu$$anonymous$$g this is what you meant :)
Yeah that's what I meant. If you are using PlayOneShot(), then you should check into the master Output field right under the Audioclip field in the audio source component. Some settings found in this field will level out the sounds played if they overlap continuously and drop the volume with consecutive plays. The behavior mentioned matches this description quite well. If that's not the problem I'll look into it and do some testing.