APawn::GetLastMovementInputVector
#include "GameFramework/Pawn.h"
Access: public
Specifiers: UFUNCTIONBlueprintCallableconst
Description
Returns the movement input vector from the most recently completed movement update. This is the value that was consumed by ConsumeMovementInputVector() during the last tick, making it useful for systems that run after the movement component.
Caveats & Gotchas
- • Animation updates run after the movement component by default, so use this function in AnimBP or AnimInstance to get input that actually drove movement — GetPendingMovementInputVector() will return zero at that point.
- • Returns a zero vector at the start of the first frame before any movement update has run. Guard against this if you need frame-one animation correctness.
Signature
FVector GetLastMovementInputVector() const; Return Type
FVector Example
Drive locomotion blend space from movement input C++
void UMyAnimInstance::NativeUpdateAnimation(float DeltaSeconds)
{
Super::NativeUpdateAnimation(DeltaSeconds);
if (APawn* Pawn = TryGetPawnOwner())
{
FVector LastInput = Pawn->GetLastMovementInputVector();
bIsMoving = !LastInput.IsNearlyZero();
MoveDirection = LastInput.GetSafeNormal();
}
} See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?