RealDocs

APawn::GetGravityDirection

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

Description

Returns the current gravity direction vector for this pawn. Used by the movement system and for physics queries in non-standard gravity scenarios.

Caveats & Gotchas

  • The base implementation queries the physics volume or world gravity; override this in custom movement components or planetary gravity setups to return the correct per-pawn direction.
  • The returned vector is a direction only and is not necessarily unit-length in all engine builds — normalise it before using it as a basis vector.

Signature

virtual FVector GetGravityDirection() const

Return Type

FVector

Example

Orient pawn to custom gravity surface C++
FVector GravDir = GetGravityDirection();
FRotator NewRot = (-GravDir).Rotation();
SetActorRotation(NewRot);

Version History

Introduced in: 5.2

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.