RealDocs

UKismetMathLibrary::Vector_SlerpVectorToDirection

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

Description

Spherically interpolates the orientation of a vector toward a target direction, preserving the original vector's magnitude. Traces an arc on the unit sphere rather than a straight line.

Caveats & Gotchas

  • The output magnitude matches the input Vector's magnitude, not Direction's. Rescale after the call if you need a specific length.
  • When Vector and Direction are nearly antiparallel, slerp is numerically unstable and can produce an arbitrary perpendicular result. Add a dot-product guard if antiparallel inputs are possible.
  • Alpha is not clamped — values outside [0, 1] extrapolate beyond the arc endpoints. Clamp manually if your source can exceed this range.

Signature

static UE_INL_API FVector Vector_SlerpVectorToDirection(FVector Vector, FVector Direction, double Alpha);

Parameters

Name Type Description Default
Vector FVector The starting vector. Its magnitude is preserved in the output.
Direction FVector The target direction to slerp toward. Its magnitude is ignored.
Alpha double Interpolation factor in [0, 1]. 0 returns Vector unchanged; 1 returns Vector's magnitude along Direction.

Return Type

FVector

Example

Smoothly steer a homing projectile toward a target C++
FVector CurrentVelocity = Projectile->GetVelocity();
FVector TargetDir = (Target->GetActorLocation() - Projectile->GetActorLocation()).GetSafeNormal();
double SteerStrength = 0.1; // 10% per frame
FVector NewVelocity = UKismetMathLibrary::Vector_SlerpVectorToDirection(CurrentVelocity, TargetDir, SteerStrength);
ProjectileMovement->Velocity = NewVelocity;

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.