UCharacterMovementComponent::GetGravityToWorldTransform
#include "GameFramework/CharacterMovementComponent.h"
Access: public
Specifiers: const
Description
Returns the cached quaternion that transforms vectors from gravity-relative space back into world space — the inverse of GetWorldToGravityTransform().
Caveats & Gotchas
- • Only meaningful when using custom gravity; with default down-gravity this is effectively identity, same as GetWorldToGravityTransform().
- • Cached and refreshed by SetGravityDirection(), not recomputed per call.
- • Prefer the RotateGravityToWorld() convenience wrapper over calling this and rotating a vector manually, unless you specifically need the raw quaternion (e.g. to set an actor's world rotation).
Signature
FQuat GetGravityToWorldTransform() const { return GravityToWorldTransform; } Return Type
FQuat Example
Converting a gravity-space direction back to world space C++
void UMyCharacterMovementComponent::ApplyWorldSpaceImpulse(const FVector& GravitySpaceDirection, float Magnitude)
{
const FQuat GravityToWorld = GetGravityToWorldTransform();
const FVector WorldDirection = GravityToWorld.RotateVector(GravitySpaceDirection);
AddImpulse(WorldDirection * Magnitude);
} See Also
Tags
Version History
Introduced in: 5.4
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?