This question was
closed Jan 12, 2019 at 02:08 AM by
Kotzuo for the following reason:
Solved by myself
Question by
Kotzuo · Jan 12, 2019 at 01:59 AM ·
audiosourcefadeout
Audio.Stop() Causing click noise even when the volume is 0
I thought making a simple fade out script would work but this noise keeps showing everytime, what do i do?
void VolumeFadeOut(AudioSource audioSource, float fadeSpeed)
{
if(audioSource.volume > 0)
audioSource.volume -= Time.deltaTime * fadeSpeed;
else
{
audioSource.Stop();
audioSource.volume = 1;
}
}
Comment
For some reason changing the function to an IEnumerator solved the problem
IEnumerator VolumeFadeOut(AudioSource audioSource, float fadeSpeed)
{
if(audioSource.volume > 0)
{
audioSource.volume -= Time.deltaTime * fadeSpeed;
yield return null;
}
else
{
audioSource.Stop();
audioSource.volume = 1;
}
}
Follow this Question
Related Questions
I'm getting an error CS1041: Identifier expected for my script? 0 Answers
can't get sound to fade out, only to fade in 1 Answer
Audio Fade In / Fade Out with Trigger 0 Answers
Audio Fade With Toggle 1 Answer
Newbie with OnTriggerEnter & Audio Files 0 Answers