Update - Thanks to everyone who replied. The problem was with the audio clip itself, adding a fade in and out removed the stutter.
I'm able to hook up a audio file/sound effect to my gun firing but there's this weird audio stutter when the weapon goes full auto. The audio seems to play fine but its like there's a weird side effect to playing a audio file in very quick succession, or playing a new audio file before the first is finished.
function LateUpdate()
{
if(can_shoot)
{
//fire pew pew
if(shot_sound)
{
audio.Stop();
audio.clip = shot_sound;
audio.Play();
}
}
}
I have no experience with audio and the sounds I'm using are the best i could build in Audacity using tones.
Any help or information would be appreciated.
Thanks for the reply. My audio file is only played when "can_shoot" is true, like when the player presses the mouse button down or when a set amount of time elapse, so its not playing every frame. The rate of fire on the weapon is 0.1 seconds, and its when the weapon fires at this speed that i get this audio problem.
– anon42863125In that cases its because your audio clip is over lapping each other. I'll update my post later - I'm in a rush at the moment.
– oliver-jones