RealDocs

ACharacter::GetReplicatedGravityDirection

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

Description

Returns the custom gravity direction replicated to simulated proxies. Used to synchronise non-standard gravity (e.g. planet surfaces) across clients.

Caveats & Gotchas

  • Only meaningful when using a custom gravity direction via CharacterMovementComponent; returns the default world gravity direction if no custom gravity is set.
  • The value is stored as FVector_NetQuantizeNormal and quantised before replication, introducing a small precision loss. Avoid using it for exact physics calculations on clients.
  • This is the replicated snapshot for simulated proxies; on the server and autonomous proxy, GetGravityDirection() from the movement component provides the authoritative live value.

Signature

ENGINE_API virtual FVector GetReplicatedGravityDirection() const

Return Type

FVector

Example

Align an effect to replicated gravity on a simulated proxy C++
FVector GravDir = SomeCharacter->GetReplicatedGravityDirection();
// Orient a visual effect opposing gravity
FRotator GravRot = FRotationMatrix::MakeFromZ(-GravDir).Rotator();
MyEffectComponent->SetWorldRotation(GravRot);

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.