Announcement

Collapse
No announcement yet.

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

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

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

    My Code:
    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?

    #2
    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.
    Marketplace: Remapt: Input Remapping System
    Tutorials: Unrealistic

    Comment


      #3
      Originally posted by Mowgl33 View Post
      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 (https://blueprintue.com/blueprint/y_zey_so/)
       
      Spoiler

      Comment

      Working...
      X