- Home /
Audio Fades
hi all .. I want to do a basic query! I have a audio which I want to convert volume 1-0 with 2 factors
script guide
audioclip MySound; float start = 3500 (Volume 1) float end = 5000 (Volume 0)
void update () { if (myscript.float = start) { mysoundsource.volume - = (here is where the volume would have to go down to 0 between 3500/5000)
what I want to do is to enter the 3500 volume and gently descend to reach the 5000 volume is 0
if someone takes a few seconds to help me or explain! you'll be grateful!
Answer by Anxo · Sep 20, 2014 at 11:39 PM
Use a lerp,
if(myscript.float == start) {
mysoundsource.volume = mathF.Lerp(mysoundsource.volume,0,Time.deltaTime);
}
Not by Unity so might error out but with that in your update it should fade from 1 to 0 over 1 second if myscript.float is equal to start. Note that in your if statement, you are declaring that myscript.float = start instead of asking myscript.float == start; be mindful of the difference between = and ==.
Your answer
![](https://koobas.hobune.stream/wayback/20220613163432im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Android Audio Delay 0 Answers
Help with Simple Footsteps? 2 Answers
AudioHighPassFilter with multiple AudioSource 1 Answer
Global audio option 2 Answers