RealDocs

UCharacterMovementComponent::GetWorldToGravityTransform

function Engine Since 5.4
#include "GameFramework/CharacterMovementComponent.h"
Access: public Specifiers: const

Description

Returns the cached quaternion that transforms vectors from world space into gravity-relative space, based on the current custom gravity direction.

Caveats & Gotchas

  • Only meaningful when using custom gravity (SetGravityDirection with a non-default direction) — with default down-gravity this is effectively identity.
  • This is a cached value updated by SetGravityDirection(), not recomputed on every call; if you mutate gravity direction through means other than SetGravityDirection, the cache can go stale.
  • Not Blueprint-exposed — use RotateWorldToGravity()/RotateGravityToWorld() helper wrappers if you just need to transform a vector rather than the raw quaternion.

Signature

FQuat GetWorldToGravityTransform() const { return WorldToGravityTransform; }

Return Type

FQuat

Example

Manually transforming a vector into gravity space C++
void UMyCharacterMovementComponent::AlignToGravitySpace(const FVector& WorldVector)
{
	const FQuat WorldToGravity = GetWorldToGravityTransform();
	const FVector GravitySpaceVector = WorldToGravity.RotateVector(WorldVector);
}

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.