I’ve been looking for ways to optimize my game and I noticed that when certain audio files are played, the script that played them spikes to over 7% usage in the Script Performance window. These audio file are over 5 minutes long and contain over a hundred different sound effects each, with each effect being separated by a few seconds. My game has 7 of these files in total, adding up to over 800 different sound effects.
When a player activates a specific event in the game, the script locates a start and end position within the audio file for the corresponding sound effect. This means that they only hear a single effect as opposed to hearing the entire audio file.
I originally set it up this way because I assumed that fewer audio files would mean the game has fewer SoundIds to load from the website, and therefore it would be more efficient. However, as I noted before, there has been a significant lag spike whenever a sound effect is played.
Testing a sound effect in its own audio file, about 1 second long, caused no noticeable spike in usage in the Script Performance window.
Would it be better to keep sounds grouped together as much as possible to reduce the amount of files that need to originally load, or would separating the effects into their own Sounds, each between 0.5 and 5 seconds long, be more efficient?
Thanks!