- Home /
When Audio is played through script it buzzes and glitches
Hello, so I have an Audio Source on an A.I when the AI starts walking the audio starts playing on loop. The noise is meant to sound like Heavy Footsteps on Metal, but all I hear is this : https://www.youtube.com/watch?v=-Mgip8HL_yQ&feature=youtu.be Does anybody know why this is happening?
Notes: The Audio Source is controlled via script. Here is basically what starts the audio playing : public AudioSource walk; walk.Play(); obviously i left out all the important bits just so you can get an easier idea of what the script does
The Audio Source is on Loop. I have tried in 2D and 3D spatial blend it still sounds the same.
Answer by unidad2pete · Aug 12, 2017 at 05:18 AM
Maybe, your script calling walk.Play(); its called on each frame. Try to check if audiosource is playing.
if(!walk.isPlaying)
{
walk.Play();
}
Answer by xyelenemuisc · Aug 13, 2017 at 09:35 AM
It shouldn't be playing every frame because the function it is a part of is only called once in the whole scene. I haven't tried the script yet but I will give it a try. I don't know if PlayOneShot would work because the audio has to loop. Any idea on how to stop it from playing every frame?
the code on my previous answer is for not playing every frame. Can share the code to check if there are any problem? or share the original audio to force the problem and check if sounds like your video.