RealDocs

UKismetMathLibrary::ProjectVectorOnToVector

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

Description

Projects vector V onto Target and returns the component of V that lies along Target. If Target is nearly zero in length, returns the zero vector.

Caveats & Gotchas

  • Returns FVector::ZeroVector when Target has near-zero length — always guard against a degenerate Target if that case is possible in your context.
  • The result is a scalar multiple of Target (parallel to it), not a perpendicular distance. To get the part of V perpendicular to Target, subtract the result from V.

Signature

static UE_INL_API FVector ProjectVectorOnToVector(FVector V, FVector Target);

Parameters

Name Type Description Default
V FVector Vector to project.
Target FVector Vector onto which V is projected.

Return Type

FVector

Example

Decompose velocity into along-slope and perpendicular components C++
FVector Velocity = GetVelocity();
FVector SlopeDir = FVector(1.f, 0.f, -0.5f).GetSafeNormal();
FVector AlongSlope = UKismetMathLibrary::ProjectVectorOnToVector(Velocity, SlopeDir);
FVector Perpendicular = Velocity - AlongSlope;

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.