RealDocs

APawn::GetGravityTransform

function Engine Since 5.4
#include "GameFramework/Pawn.h"
Access: public Specifiers: virtualconst

Description

Returns a quaternion that transforms from world space into gravity-relative space, where the negative Z axis aligns with the gravity direction. Used by movement components and physics-aware systems to operate correctly on non-standard gravity surfaces.

Caveats & Gotchas

  • The default implementation derives the quaternion from GetGravityDirection(), which returns (0,0,-1) by default — overriding GetGravityDirection() alone is sufficient unless you need custom transform logic.
  • This is called per-frame by CharacterMovementComponent in gravity-relative movement modes; heavy overrides will impact performance on large numbers of pawns.

Signature

virtual FQuat GetGravityTransform() const

Return Type

FQuat

Example

Orient a vector to gravity-relative space C++
FQuat GravRot = MyPawn->GetGravityTransform();
FVector LocalVelocity = GravRot.RotateVector(MyPawn->GetVelocity());
// LocalVelocity.Z is now the speed along the gravity axis

Version History

Introduced in: 5.4

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.