UCharacterMovementComponent::RevertMove
#include "GameFramework/CharacterMovementComponent.h"
Access: public
Description
Restores the character's position, base, and floor state to a previous snapshot, undoing a move that turned out to be invalid.
Caveats & Gotchas
- • Not virtual — you cannot override its behaviour in a subclass, only call it as-is from custom movement code.
- • bFailMove additionally halts movement and notifies the controller, which can trigger gameplay-visible effects (e.g. AI move failure handling); pass false if you just want to restore position silently.
- • Used internally when a walk move ends up somewhere invalid (e.g. failed ledge check); calling it with mismatched OldLocation/OldBase/OldFloor snapshots can leave the movement component in an inconsistent state.
Signature
void RevertMove(const FVector& OldLocation, UPrimitiveComponent* OldBase, const FVector& InOldBaseLocation, const FFindFloorResult& OldFloor, bool bFailMove); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| OldLocation | const FVector& | Location to revert the character back to. | — |
| OldBase | UPrimitiveComponent* | Movement base to restore as the character's current base. | — |
| InOldBaseLocation | const FVector& | Base location to restore into OldBaseLocation. | — |
| OldFloor | const FFindFloorResult& | Floor result to restore as CurrentFloor. | — |
| bFailMove | bool | If true, also stops movement and notifies the controller that the move failed. | — |
Return Type
void Example
Reverting a move after a custom validity check fails C++
void UMyCharacterMovementComponent::TryCustomStep(const FVector& OldLocation, const FFindFloorResult& OldFloor)
{
if (!IsNewPositionValid())
{
RevertMove(OldLocation, GetMovementBase(), OldBaseLocation, OldFloor, /*bFailMove=*/true);
}
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?