Just found this out recently when I was about to make an effect for my game where an explosion will temporarily impair your hearing (muffle it). But it works with the ambience noise that uses “play-on-awake” and “loop”. I tried converting my gun script (which contains gunshot sounds), from audio.PlayOneShot to audio.Play, and it works. But, PlayOneShot allows for audio clips to overlap each other. And I don’t want to instantiate sound effects either. Did anyone else have this issue? I mean, this isn’t important, but it would add a nice effect to my game.
Summary: If you didn’t feel like reading the above, then here is a simplified version…
Added a low pass filter to audio source. Audio sources that uses audio.Play will work properly, however audio.PlayOneShot will ignore the low pass filter.
Thanks for reading and I hope I’m not the only one having this issue.
I have a hard object which falls around and impacts the environment, sometimes a number of times in quick succession.
I need to trigger one of five randomly chosen impact sounds and allow the sounds to overlap and add to each other, not cut each other off. I also need to apply a reverb filter.
Strange this hasn’t come up anywhere else I can see.
Managing multiple audio sources and hence having limited polyphony to achieve this is cumbersome, hoping there’s a way to use playoneshot with effects as I don’t see why this should be a restriction technically.
I think this is because PlayOneShot simply creates a new temporary GameObject with an AudioSource on it (I know PlayClipAtPoint works this way). Because that new GameObject has no reverb/lowpass/whatever component, it doesn’t get the effect. I think that if instead you picked your random clip, then assigned it to the clip property of your current audio source, then played it, you’d get the effect you want.
I used to do a lot of actual FMOD programming at my prev game company, and it’s a bit of a shame that Unity uses components for all of these features. There are much more efficient ways to do it w/ direct access.
PS - The various game audio kits are designed to solve this problem, too, esp w/ the whole cutoff thing. I’m actually working on a kit of my own that adds some new cool features. I’ll post more when that’s ready but in the mean time you might want to look into Audio Kit or the like.