- Home /
Question by
SirMalarkey · Apr 03, 2013 at 09:37 AM ·
camerascalefovreal-time
how to scale a cameras FOV in real time.
i am creating a fps camera, and when the player sprints i want the FOV to smoothly scale from 80 to 90. I tried using Mathf.Lerp(80,90,Time.time); but that just caused it to instantly pop from 80 to 90, if i use deltaTime the fov will only go from 80 to 91, if anyone has a solution to this i would be very happy to hear it.
Comment
Answer by gheeler · Apr 03, 2013 at 09:44 AM
float moved = 0;
void Update ()
{
Mathf.Lerp(80,90,moved);
moved += Time.DeltaTime * scalingFactor;
}
then just check for moved being >= 1
the value moved has to be between 0 and 1. time.deltatime will be the same every time and Time.time is > 1 so will go straight to the target value