Hi FMOD users! I have a Unity project where I am using FMOD event emitters triggered by object start and destroy that are synced to line up with an animation that’s on a loop. Player enters the 3D sounds attenuation field and you hear the sound. In Unity Editor, the audio is perfectly in sync with the animation. When I build the macOS build and launch, just the first playthrough of that scene (or any other scenes with this same audio feature) the audio is off sync, however if I launch the build again (or even launch the scene within the same initial build first playthrough) it’s now perfectly in time. It seems to happen across computers and users but always is fixed when the scene or the build is reloaded, it then works right even days later launching the app again. This is global with all sounds in that scene that use the object start/destroy as trigger, even if I don’t play long enough to see them out of sync, the relaunch of the game or the scene fixes it. I’m not a programmer hence why I’m not using code to trigger an animation event via the animation in Unity and do it that way (did that with footsteps and those worked fine but I’m a very novice coder and this seemed like an easier solution for me, and I also have audio files longer than animations so that really wouldn’t work right either) Even with my limited knowledge I have a suspicion that it’s trying to load the audio to trigger on the first scene load in the build and something is causing an initial delay that somehow gets fixed just loading the scene again. I tried updating to newest versions of Unity and FMOD and the plugin, (Unity 2022.3.14f1, FMOD 2.02.19, Unity’s FMOD package is also up to date) and then I also split all the scene’s banks up per scene to have less of an initial load of banks at start time and nothing worked so far. Does anyone have an idea of what’s going on or possibly a simple solution here for me to help solve this? I know it’s a band aid idea for a solution but is there a simple line of code I could run before the build plays to load and unload the whole game’s audio to fix this before the scene loads? Thanks again for looking!
Unfortunately, I’ve been unable to reproduce the issue you’re describing on my end. It does sound like some kind of caching-related issue, but FMOD shouldn’t be doing anything different on the first load vs other loads, so it may be an issue with Unity.
Are you able to reproduce the issue with a fresh Unity project? Additionally, do you find that your built Unity project generates any files on its first run? If so, if you delete those files, do you find that the issue reoccurs? I would also recommend connecting your built project to the Unity profiler and seeing whether you observe a significant difference in resource utilization or load time on the first run vs subsequent runs.
If you’re unable to resolve the issue, and you’re manually starting your animation and FMOD event instance simultaneously from code, you may wish to drive the start of your animation from an event callback. This will involve doing some coding as opposed to just using the FMOD components, but should allow for the FMOD system to call for your animation to start when your event instance reaches a specific state, instead of you starting them in parallel and hoping they start synced. Our Timeline Callbacks example demonstrates using an event callback to receive information from the timeline, but you can set it to use any
FMOD_EVENT_CALLBACK_TYPE, such as