RealDocs

ACharacter::GetGravityTransform

function Engine Since 5.4
#include "GameFramework/Character.h"
Access: public Specifiers: virtualoverride

Description

Returns a quaternion that rotates from world space into gravity-relative space, allowing movement and orientation calculations to be performed relative to the current gravity direction.

Caveats & Gotchas

  • In a standard single-gravity world this returns an identity-equivalent quaternion aligned with world down. Its value only diverges from the identity when custom gravity directions are active (e.g. planet gravity or wall-walking).
  • CharacterMovementComponent uses this to transform velocity and acceleration into the reference frame of gravity before integration — overriding it without also overriding GetGravityDirection will produce inconsistent results.
  • On simulated proxies the gravity direction is taken from the replicated ReplicatedGravityDirection, not from a physics query, so there is an inherent one-replication-tick lag.

Signature

ENGINE_API virtual FQuat GetGravityTransform() const override

Return Type

FQuat

Example

Transform a world-space vector into gravity-relative space C++
FQuat GravQuat = GetGravityTransform();
FVector GravRelativeVelocity = GravQuat.RotateVector(GetVelocity());
UE_LOG(LogTemp, Log, TEXT("Gravity-relative velocity: %s"), *GravRelativeVelocity.ToString());

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.