Probably I’m not using the right delta time or the different between both locations is to small.
How can I use VInterpTo?
I have also tried to increment the different between the two locations:
void AMyPawn::DoSphericalZoom(bool bIsIn)
{
InitZoomVars();
// If we are doing zoom in...
if (bIsIn)
{
CurrentZoomRadius -= ZoomRadiusIncrement;
if (CurrentZoomRadius < ZoomRadiusIncrement)
CurrentZoomRadius = ZoomRadiusIncrement;
}
// ... or zoom out.
else
{
CurrentZoomRadius += ZoomRadiusIncrement;
if (CurrentZoomRadius > SphereZoomCoors.Radius)
CurrentZoomRadius = SphereZoomCoors.Radius;
}
FVector NewLocation =
SphericalToCartesian(SphericalCoordinates{ CurrentZoomRadius, SphereZoomCoors.Azimuth, SphereZoomCoors.Zenit });
// Add the centre location of the object I will do zoom to it because I get the location shifted to that centre.
NewLocation += OriginLocation;
FVector CurrentLocation = GetActorLocation();
UE_LOG(LogTemp, Warning, TEXT("CurrentLocation: %s, NewLocation : %s"), *CurrentLocation.ToString(), *NewLocation.ToString());
FMath::VInterpTo(CurrentLocation, NewLocation+1000.0, DeltaTime * 50.0, InterpSpeed);
//SetActorLocation(NewLocation);
// Check if we are in our starting camera location.
bIsInitialCameraLocation = (InitialCameraLocation == GetActorLocation());
}
Are you updating CurrentLocation?
InterpTo works differently from Lerps.
With Lerp you set initial location and target location, and alpha interpolates between those two.
InterpTo calculates the distance from current location to target location and moves the object a bit. If your CurrentLocation variable doesn’t change, it will move the object to the same spot over and over. That’s why you have to update Current Location every tick. Or simply use GetActorLocation() in the VInterpTo function.
Wait, your function FMath::VInterpTo(CurrentLocation, NewLocation+1000.0, DeltaTime * 50.0, InterpSpeed); is performed, but it doesn’t update anything. It should be something like this:
If it helps to think about it, movement is done through the Transform or PlayerController, so if you don’t have to pass these, or call from these, then no movement will occur.
When you use something like VInterpTo, it’s giving you the new frame based position the character *should be moved to, based on position, destination, time between frames, speed of character.
I think the documentation assumes you have prior knowledge of SLerps/Lerps and other functionality from other engines.