Too many PlayOneShot method calls causing freezes

Some of my enemies get bunched up and hit rapidly. Each hit causes a ‘FMODUnity.RuntimeManager.PlayOneShot’ to fire, resulting in thousands of PlayOneShot method calls. The frame rate gets slower and slower.
I suspect I don’t want to be calling PlayOneShot hundreds of times in a single frame for the same sound event that’s pretty much in the same location. Is there an FMOD specific technique I can use here to play these sound events more efficiently?
Thanks!

There are a few different things you could try, depending on what you need.

  • Giving the event a cooldown will prevent it from triggering again for a short while after it plays. Cooldown can be set in the event macro controls.
  • Setting the max instances of the event to a value less than infinity will constrain the number of simultaneous instances of that event. Max instances can be set in the event macro controls.
  • It goes without saying that you could adjust your game’s code to not call FMODUnity.RuntimeManager.PlayOneShot as often as it currently does.
2 Likes

tyty, I’ll give those a try

1 Like