UAnimInstance::SetRootMotionMode
#include "Animation/AnimInstance.h"
Access: public
Specifiers: ENGINE_API
Description
Changes the root motion extraction mode at runtime, controlling whether and how root motion from animations is applied to the owning character's movement. Useful for toggling root motion on cutscene entry/exit or switching between locomotion styles.
Caveats & Gotchas
- • Changing root motion mode mid-montage can cause a position discontinuity because in-flight root motion that has already been accumulated is not retroactively cancelled. Always change the mode at a natural animation boundary.
- • This setter updates RootMotionMode on the AnimInstance but the CharacterMovementComponent also caches root motion state each frame. If you change the mode after the movement component has already consumed root motion for the frame, the change won't take effect until the next frame.
Signature
ENGINE_API void SetRootMotionMode(TEnumAsByte<ERootMotionMode::Type> Value); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Value | TEnumAsByte<ERootMotionMode::Type> | The new root motion extraction mode (NoRootMotionExtraction, IgnoreRootMotion, RootMotionFromEverything, RootMotionFromMontagesOnly). | — |
Return Type
void Example
Switch to no root motion for a cutscene C++
void AMyCharacter::StartCutscene()
{
if (UMyAnimInstance* AI = Cast<UMyAnimInstance>(GetMesh()->GetAnimInstance()))
{
AI->SetRootMotionMode(ERootMotionMode::NoRootMotionExtraction);
}
} Tags
Version History
Introduced in: 4.5
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?