Download

Bug or future inside in FMath::RInterpTo function?

Hi all !
Recently, I wanted to calculate the aming rotation and write as it :

AimingRotation = FMath::RInterpTo(AimingRotation, ControlRotation, DeltaSeconds, AimingRotationInterpSpeed);

In the process, everything was calculated expected
But as soon as the rotation stopped( Delta is nearly zero), the AimingRotation changed.
I looked into the function code

// If steps are too small, just return Target and assume we have reached our destination.
if (Delta.IsNearlyZero())
{
return Target;
}
// Delta Move, Clamp so we do not over shoot.
const FRotator DeltaMove = Delta * FMath::Clamp(DeltaInterpSpeed, 0.f, 1.f);
return (Current + DeltaMove).GetNormalized();

if Delta is so small returned not ormalized Target else returned normalized result.

I have a question, was it so conceived or here a logical bug?

When two normalized vectors/rotators (length = 1) are added together, the result will be a non-normalized vector (length ≠ 1), so the result needs to be normalized. The target doesn’t need to be normalized since it’s already normalized.

Yeah, you right. I’m use AController::ControlRotation as Target, and he is not normalized.
But in docs, has`t info about it. :thinking:

Thank you!