Setting slider value over time using C# script?
I've been playing around with a couple of ways to do this but it doesn't seem to be working. I'm trying to achieve the following - On button click, launching a script that changes a slider value from 0.85 to 1.15 over an amount of time. I've tried using :
Slider.value = Mathf.Lerp (0.85F, 1.15F, Time.deltaTime / 5);
in the hope that it would go from one value to the other over 5 seconds, but instead it just seems to change the value after 0.85 back and fourth (eg 0.85xxx). I've spent the last 4 hours trying to get my head around why Lerp isn't working and I'm pretty confident it's something I'm doing wrong. I am also wondering if using the Lerp command is even the best way to do what I'm after? I don't want the value to change until the button is clicked, and once another button is clicked I want the value to go back to normal. How is the best way to achieve this? Any help is appreciated!