FInterpTo in Spark

Hello everyone!

is there any alternative to “FInterpTo” of UE within SparkAR? Does anyone know the calculation for the interpolation with delta time?

Do you have the UE source on your computer? The path to the code is shown in this doc, but there’s no link to it. FMath::FInterpTo | Unreal Engine Documentation

Here’s the process for getting the source code. You might be able to translate it directly into SL now that we have the delta time variable.

CORE_API float FMath::FInterpTo( float Current, float Target, float DeltaTime, float InterpSpeed )
{
	// If no interp speed, jump to target value
	if( InterpSpeed <= 0.f )
	{
		return Target;
	}

	// Distance to reach
	const float Dist = Target - Current;

	// If distance is too small, just set the desired location
	if( FMath::Square(Dist) < SMALL_NUMBER )
	{
		return Target;
	}

	// Delta Move, Clamp so we do not over shoot.
	const float DeltaMove = Dist * FMath::Clamp<float>(DeltaTime * InterpSpeed, 0.f, 1.f);

	return Current + DeltaMove;
}
2 Likes