I’ve got not much idea about game developing and now I want to do move an actor smoothly. Searching I’ve found that I could use VInterpTo, but I don’t know how this method works:
I don’t understand interpolation. When I use VInterpTo I don’t know how it works. I think I set a start point, an end point, a delta (???) and a speed. Then, the method returns a value. Here it comes my problem, how can I use this method? Maybe, the method split the distance between the end and the start point using delta and speed, and I have to call it several times until start is equal to end point. And, in the process I have to use the returned value of the method as the new start point in the next call.
CORE_API FVector FMath::VInterpTo( const FVector& Current, const FVector& Target, float DeltaTime, float InterpSpeed )
{
// If no interp speed, jump to target value
if( InterpSpeed <= 0.f )
{
return Target;
}
// Distance to reach
const FVector Dist = Target - Current;
// If distance is too small, just set the desired location
if( Dist.SizeSquared() < UE_KINDA_SMALL_NUMBER )
{
return Target;
}
// Delta Move, Clamp so we do not over shoot.
const FVector DeltaMove = Dist * FMath::Clamp<float>(DeltaTime * InterpSpeed, 0.f, 1.f);
return Current + DeltaMove;
}
It first gets the distance between the two vectors. Then multiplies that Distance with Speed and DeltaTime. Then adds it the Current vector and returns that.