RealDocs

UKismetMathLibrary::ProjectVectorOnToPlane

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

Description

Removes the component of V that is parallel to PlaneNormal, returning only the part of V lying within the plane. Equivalent to V minus the projection of V onto the normal.

Caveats & Gotchas

  • PlaneNormal must be normalized; an unnormalized normal causes the result to be scaled incorrectly. The function does not normalize it internally.
  • The returned vector is generally shorter than V unless V is already in the plane. Do not assume the output is a unit vector even if V was one.

Signature

static UE_INL_API FVector ProjectVectorOnToPlane(FVector V, FVector PlaneNormal);

Parameters

Name Type Description Default
V FVector Vector to project onto the plane.
PlaneNormal FVector Normalized normal of the plane.

Return Type

FVector

Example

Flatten a movement direction onto a surface C++
FVector MoveDir = FVector(1.f, 0.f, -1.f).GetSafeNormal();
FVector SurfaceNormal = HitResult.Normal;
FVector FlatDir = UKismetMathLibrary::ProjectVectorOnToPlane(MoveDir, SurfaceNormal).GetSafeNormal();

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.