I am making a WWII game and I have flak firing at me.
Sometimes, when the explosion is spawned the sound will just click and not play properly, like you won’t hear the normal audio file but instead unity gives me some CLICK sound.
This is super odd as it is totally random, like it doesn’t seem to follow any kind of pattern or logic. I thought at first that it was all of those who weren’t in my camera’s FOV that were clicking but I ruled that out when I did testing and all were in the FOV of my camera … So … I am pretty lost here I can’t explain this behaviour
my .wav file has also been uploaded so you can have a look at it, but again, I am using this sound at different places in the game and it doesn’t have any issue.
Any explanations to this strange behaviour?
I am on MacOS 12.3.1 on a MacBook Pro 16" M1 Pro using Unity LTS 2021.3.0 This bug was present on older versions as well such as 2020.3.33f1 LTS
The fix was to disable Doppler Effect
But why? Why is this creating an audio glitch?
My first thought is either clipping (eg, the volume is too high on the sound), or else you are starting / stopping / restarting the flak sound rather than letting it play to completion.
Massively turn down the volume on ALL the audio sources to perhaps 0.1 and see if the problem goes away. If it goes away, it was clipping.
If it is still present, then begin investigating if you are telling fresh sounds to play before the previous one finished.
Thanks @Kurt-Dekker for your fast response
I managed to “solve” it by disabling Doppler effect on the audiosource.
Do you thinking moving at high speed (600km/h) while playing a sound nearby could somehow sometimes result in such a glitch?
Interesting. Doppler will change the frequency… I’m not sure what calculations Unity uses for this but naively increasing frequency will increase apparent volume, possibly resulting in clipping being more noticeable.