I want to change FOV(Field of view) value while MovingForward action

I have situation. I want smoothly change FOV while moving forward. In Camera settings in parent class I set default value:


FollowCamera->FieldOfView = 90.0f;

Then in MoveForward function do this.


//Angle of direction of camera on Yaw
const FRotator Rotation = Controller->GetControlRotation();
const FRotator YawRotation(0, Rotation.Yaw, 0);

const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
AddMovementInput(Direction, Axis);

FollowCamera->FieldOfView = 140.0f;
}

Actually it works, so when I move forward FOV changes to 140, but it works really roughly and instantly. I want to do it smoothly from 90 to 140. Can you help me with it?

  • define min and max fov
  • define transition time from min to max (and the other way)
  • use one of the Lerp functions to interpolate FOV between min and max each Tick()
  • you’ll want to include delta time in the calculation

https://docs.unrealengine.com/en-US/…erp/index.html

Thank you.

I tried with FInterpTo : https://docs.unrealengine.com/en-US/…pTo/index.html
Each times the “MoveForward” will be called, the fov will be increased until 140. To slow/speed the transition, decrease/increase the InterpSpeed value

But anyway thank you. This also should work.