VInterpTo doesn't smoothly move camera

What you need to do it update the currentCameraPos each tick. So it should look something like this:

void ATheMeadowsCharacter::Tick(float DeltaSeconds)
 {
     Super::Tick(DeltaSeconds);
 
     if (isSwitchedCamera == true)
     {
         FVector currentCameraPos = FMath::VInterpTo(currentCameraPos, cameraTransformA, GetWorld()->GetDeltaSeconds(), 0.5f);
         FollowCamera->SetRelativeLocation(currentCameraPos);
         isSwitchedCamera = false;
     }
 }

This doesn’t work. It makes my camera shoot outside of the map!

Oh ■■■■, I think I know what the problem is. You’re passing deltatime, but that’s probably around 0.00833 every time, but you aren’t accumulating it anywhere to have it actually increase it’s value, so try accumulating it in a float and passing it in like this:

float _accumulatorFloat; 

void ATheMeadowsCharacter::SwitchCamera()
 {
     currentCameraPos = cameraTransformA;
     cameraSwitch = !cameraSwitch;
 
     if (cameraSwitch == false)
     {
         cameraTransformA.X = 20.0f;
         cameraTransformA.Y = 40.0f;
         cameraTransformA.Z = 40.0f;
     }
     else if (cameraSwitch == true)
     {
         cameraTransformA.X = 20.0f;
         cameraTransformA.Y = -40.0f;
         cameraTransformA.Z = 40.0f;
     }
     _accumulatorFloat = 0.0f;
     isSwitchedCamera = true;
 }
 
 void ATheMeadowsCharacter::Tick(float DeltaSeconds)
 {
     Super::Tick(DeltaSeconds);
 
     if (isSwitchedCamera == true)
     {
         _accumulatorFloat += DeltaSeconds;
         FVector finalCamPos = FMath::VInterpTo(currentCameraPos, cameraTransformA, _accumulatorFloat , 0.5f);
         FollowCamera->SetRelativeLocation(finalCamPos);
         isSwitchedCamera = false;
     }
 }

I was making assumptions that everything else was correct. Let me rewrite it and explain it and you can make sure its correct:

 void ATheMeadowsCharacter::Tick(float DeltaSeconds)
  {
      Super::Tick(DeltaSeconds);
  
      if (isSwitchedCamera == true)
      {
         currentCameraPos = FMath::VInterpTo(currentCameraPos, targetCameraPos, DeltaSeconds, 0.5f);
          FollowCamera->SetRelativeLocation(currentCameraPos);
      }
      if (currentCameraPos == targetCameraPos)
      {
          isSwitchedCamera = false;
      }
  }

Now for this to work you character will need two member variables currentCameraPos and targetCameraPos that is because these variables need to exist longer than once per tick.

How the guts of interpolates work is that you give it a the first param is usually your current then the second param is where you want to go. Interpolates will keep updating the current value until it’s equal to the target. However it isn’t a call once and done function.

for example if your current is 10 and your target is 15. The first tick will set current to 10.5. Then the second time tick is called your current is 10.5 and your target in 15 and then it’ll update current again 11. This is why having the position be member variables is important.

I hope this helped let me know if you have any other questions.

Thats not how interpolate works. You are not trying to accumulate the delta seconds. That is merely a multiplier for the speed.

current = current + (deltaseconds * speed)

the delta seconds are there because tick is called every frame which may be faster or slower depending on your computer. This way computers running at 60 frames per second wont be faster than a computer running at 30 fps

Bro your a genius! ■■■■■■■ hell. This works perfectly however you have to take the isSwitchedCamera = false out, otherwise it just runs once. Thank you sooooo much. I can’t be more grateful.

Hahah no worries, it tripped me up as well. I posted a corrected code snippet below if you need it.

Ahh that’s great thanks! So is the whole point of creating VInterpTo inside the current so that it updates the position?