Hey guys! Sorry to bother you all but I’m finding it extremely difficult to pinpoint this problem. I’ve tried searching online, posted in the answer hub but none of us were able to come up with a solution. I have a VInterpTo which should be smoothly moving a camera from one point to another in relative space. Although the camera moves to the specified location, it jumps to it - teleports. Here is the code:
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;
}
isSwitchedCamera = true;
}
void ATheMeadowsCharacter::Tick(float DeltaSeconds)
{
Super::Tick(DeltaSeconds);
if (isSwitchedCamera == true)
{
FVector finalCamPos = FMath::VInterpTo(currentCameraPos, cameraTransformA, DeltaSeconds, 0.5f);
FollowCamera->SetRelativeLocation(finalCamPos);
}
}
I tried debugging the code and found both values: currentCameraPos and cameraTransformA were indeed different. When I stepped into the VInterpTo function, the values were as expected with the InterpSpeed being 0.5. If anybody could help then I would be forever grateful.
Thanks!