I want my fov to increase as my player sprints, but whenever i press shift to sprint it keeps updating and makes my Fov continuously updates and keeps increasing to an ungodly level, who do i make it happen only once, each time i sprint.
whole update:
void FixedUpdate()
{
baseFov = NormalCam.fieldOfView;
float t_hmove = Input.GetAxisRaw("Horizontal");
float t_vmove = Input.GetAxisRaw("Vertical");
bool sprint = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);
bool IsSprinting = sprint && t_vmove > 0;
Vector3 t_direction = new Vector3(t_vmove, 0, t_hmove);
t_direction.Normalize();
float t_adjustedSpeed = speed;
if (IsSprinting) t_adjustedSpeed *= sprintModifier;
rig.velocity = transform.TransformDirection (t_direction) * t_adjustedSpeed * Time.deltaTime;
if (IsSprinting) { NormalCam.fieldOfView = Mathf.Lerp(NormalCam.fieldOfView, baseFov * SprintFovModifier, Time.deltaTime * 8f); }
else { NormalCam.fieldOfView = baseFov; }
}
just fov stuff:
if (IsSprinting) { NormalCam.fieldOfView = Mathf.Lerp(NormalCam.fieldOfView, baseFov * SprintFovModifier, Time.deltaTime * 8f); }
else { NormalCam.fieldOfView = baseFov; }