The best way to zoom camera(change FOV) Tick or somehow using a timer?

My Code:


// Called every frame
void ASCharacter::Tick(float DeltaTime)
{
    Super::Tick(DeltaTime);

    float TargetFOV = bWantsToAimDownSights ? DownSightsFOV : DefaultFOV;

    float NewFOV = FMath::FInterpTo(CameraComp->FieldOfView, TargetFOV, DeltaTime, DownSightsSpeed);
    CameraComp->SetFieldOfView(NewFOV);
}

Is it okay, or it does too much overhead/may cause performance issues?

Help me to find it out!
if someone can do it using a timer, please show the way how it should look like or just the logic. (Is it should change the currentFOV every N seconds, and then set the loop to true in timer?

Tick is generally frowned upon. If you can put it in a timer, you should. And you can.

Here’s a start:

  1. Create zoom interp function
  2. Set timer with zoom function when AimDownSights input occurs (storing TimerHandle somewhere)
  3. Clear timer when FOV == ZoomFOV
  4. Do the reverse to get back to normal FOV

You can find more info on timers (and timer delegates) on the UE4 documentation page. Try figuring it out on your own first, then come back if you hit a wall.

My temporary fix in BP (Down sight aiming (2 cameras) posted by UtmostCreator | blueprintUE | PasteBin For Unreal Engine)