RealDocs

UKismetMathLibrary::GetSlopeDegreeAngles

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

Description

Decomposes a floor normal into separate pitch and roll angles, relative to an actor's right vector and a reference up vector. Used to lean or tilt a character or object to match sloped ground.

Caveats & Gotchas

  • MyRightYAxis, FloorNormal, and UpVector must all be unit (normalized) vectors — passing non-normalized input silently produces incorrect angles rather than an error.
  • The output is split into pitch and roll rather than a single slope angle, so it only makes sense in a context where the actor has a well-defined right axis (e.g. a character capsule), not for arbitrary objects.
  • This has no return value; both outputs must be read via the reference parameters, which in Blueprint appear as separate output pins.

Signature

static void GetSlopeDegreeAngles(const FVector& MyRightYAxis, const FVector& FloorNormal, const FVector& UpVector, float& OutSlopePitchDegreeAngle, float& OutSlopeRollDegreeAngle)

Parameters

Name Type Description Default
MyRightYAxis const FVector& Right (Y) direction unit vector of the actor standing on the slope.
FloorNormal const FVector& Unit normal vector of the floor surface.
UpVector const FVector& Up vector of the reference frame (typically world up).
OutSlopePitchDegreeAngle float& Receives the slope's pitch angle in degrees.
OutSlopeRollDegreeAngle float& Receives the slope's roll angle in degrees.

Return Type

void

Example

Tilt a character mesh to match ground slope C++
FVector RightAxis = GetActorRightVector();
FVector FloorNormal = HitResult.ImpactNormal;
float Pitch, Roll;
UKismetMathLibrary::GetSlopeDegreeAngles(RightAxis, FloorNormal, FVector::UpVector, Pitch, Roll);
GetMesh()->SetRelativeRotation(FRotator(Pitch, 0.f, Roll));

Version History

Introduced in: unknown

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.