I want to lerp the players cameras field of view when he accelerates with a booster and have it come back slowly to 60.
The first line of code is how I lerp from the value 60 to 62.7 which is supposed to happen faster than when it comes back from 62.7f to 60 (line two is in a coroutine and is activated after 1 second of the initial lerp) But the problem is that the lerping happens almost instantly on both, it’s as though the Mathf.Lerp is obsolete or not there at all, does anyone know why or how to control the speed of the lerp better?
This should not really do what you want it to do. The third argument is the progress between 0 and 1 (0 means returning argument one, 1 means returning argument two, every other value is linear interpolation between the two). Instead you will need a variable that holds the current progress and is increased by Time.deltaTime and use that as the third variable.
Thank you for your help but it’s the same result as my line of code. The movement is instant for some reason, it doesnt change based on the value of “MovementPerSecond”.
So you want to have a kinda visual boost effect by increasing / decreasing the Camera FOV with a smooth transition between the two states.
My humble advice is that the use of a Coroutine could be a bit complicate since you dont know the time that will take to run from 60.0f to 62.7f … Or you may be have to calculate it…
Use instead a simple boolean that says : I have to increase / decrease the FOV. And use Mathf.Approximately()in the increase mode to know if you have reached 62.7f so you can switch to the decrease mode.
In the he vid below OnTriggerEnter() is used to “PingPong” the FOV. But i think it can work with other events.