UKismetMathLibrary::Vector_ProjectOnToNormal
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticBlueprintPure
Description
Projects V onto InNormal, returning the component of V that lies along InNormal. Equivalent to (V dot InNormal) * InNormal.
Caveats & Gotchas
- • InNormal must be unit length. If it is not normalized, the result is scaled incorrectly — the projected length will be proportional to InNormal's magnitude squared. Normalize it with Normal() before passing.
- • The result is a *vector* along InNormal, not a scalar length. To get the scalar signed length of the projection, use the dot product: FVector::DotProduct(V, InNormal). Confusing the two is a common source of incorrect plane-alignment math.
Signature
static UE_INL_API FVector Vector_ProjectOnToNormal(FVector V, FVector InNormal); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| V | FVector | The vector to project. | — |
| InNormal | FVector | The unit-length vector to project onto. | — |
Return Type
FVector Example
Decompose velocity into vertical and horizontal components C++
FVector Vel = Character->GetVelocity();
FVector UpNormal = FVector::UpVector;
FVector VerticalVel = UKismetMathLibrary::Vector_ProjectOnToNormal(Vel, UpNormal);
FVector HorizontalVel = Vel - VerticalVel;
float HorizSpeed = HorizontalVel.Size(); Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?