UCharacterMovementComponent::GetGravitySpaceComponentZ
#include "GameFramework/CharacterMovementComponent.h"
Access: public
Specifiers: constinline
Description
Returns the component of a vector that lies along the current gravity-space vertical axis, as a vector rather than a scalar.
Caveats & Gotchas
- • Not Blueprint-exposed — it's a header-only inline helper, so it can only be called from C++.
- • Under default world gravity this is equivalent to isolating the world Z component, but it tracks GetGravityDirection() so it stays correct under custom per-character gravity.
- • Returns a vector aligned with the gravity axis, not a scalar magnitude — use GetGravitySpaceZ() if you just need the signed distance.
Signature
FVector GetGravitySpaceComponentZ(const FVector& Vector) const { return Vector.Dot(GetGravityDirection()) * GetGravityDirection(); } Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Vector | const FVector& | The vector to decompose. | — |
Return Type
FVector Example
Isolate the vertical component of velocity under custom gravity C++
UCharacterMovementComponent* MoveComp = GetCharacterMovement();
FVector VerticalVelocity = MoveComp->GetGravitySpaceComponentZ(MoveComp->Velocity); Version History
Introduced in: 5.4
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?