RealDocs

UKismetMathLibrary::Quat_Slerp

function Engine Blueprint Since 4.0
#include "Kismet/KismetMathLibrary.h"
Access: public Specifiers: staticBlueprintPure

Description

Performs spherical linear interpolation between two quaternions and returns a normalized result. Produces the shortest constant-angular-velocity path between the two orientations.

Caveats & Gotchas

  • When A and B represent opposite orientations (dot product near -1), Slerp is numerically unstable and may flip; internally UE negates B if the dot product is negative to ensure the short path, but check the engine version to confirm this behavior.
  • Alpha is not clamped internally; values outside [0,1] will extrapolate beyond A and B, which can produce unexpected results if the caller does not clamp first.

Signature

static UE_INL_API FQuat Quat_Slerp(const FQuat& A, const FQuat& B, double Alpha);

Parameters

Name Type Description Default
A const FQuat& Starting quaternion (Alpha = 0).
B const FQuat& Target quaternion (Alpha = 1).
Alpha double Interpolation factor in the range [0, 1].

Return Type

FQuat

Example

Smoothly interpolate actor rotation each frame C++
void AMyActor::Tick(float DeltaTime)
{
    Super::Tick(DeltaTime);
    FQuat Current = GetActorQuat();
    FQuat Target = TargetActor->GetActorQuat();
    float Alpha = FMath::Clamp(DeltaTime * RotationSpeed, 0.f, 1.f);
    FQuat NewRot = UKismetMathLibrary::Quat_Slerp(Current, Target, Alpha);
    SetActorRotation(NewRot);
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.