APawn::ConsumeMovementInputVector
#include "GameFramework/Pawn.h"
Access: public
Specifiers: virtualUFUNCTIONBlueprintCallable
Description
Returns the accumulated pending movement input and resets it to zero, copying it to the last input vector. Called once per movement update by PawnMovementComponent to prevent input from accumulating across frames.
Caveats & Gotchas
- • Calling this more than once per frame will return zero on the second call — the pending vector is cleared on the first consume. PawnMovementComponent calls this automatically, so custom movement code should not call it again unless you bypass the movement component entirely.
- • The consumed value is copied to LastControlInputVector before zeroing, so GetLastMovementInputVector() remains valid after the call.
Signature
virtual FVector ConsumeMovementInputVector(); Return Type
FVector Example
Custom movement component consuming input C++
void UMyMovementComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
APawn* Owner = GetPawnOwner();
if (!Owner) return;
FVector Input = Owner->ConsumeMovementInputVector();
if (!Input.IsNearlyZero())
{
FVector Delta = Input.GetSafeNormal() * MaxSpeed * DeltaTime;
MoveUpdatedComponent(Delta, UpdatedComponent->GetComponentQuat(), true);
}
} See Also
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?