UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FRootMotionSource Struct Reference

#include <RootMotionSource.h>

+ Inheritance diagram for FRootMotionSource:

Public Member Functions

ENGINE_API FRootMotionSource ()
 
virtual ~FRootMotionSource ()
 
ENGINE_API float GetTime () const
 
ENGINE_API float GetStartTime () const
 
ENGINE_API bool IsStartTimeValid () const
 
ENGINE_API float GetDuration () const
 
virtual ENGINE_API bool IsTimeOutEnabled () const
 
virtual ENGINE_API FRootMotionSourceClone () const
 
virtual ENGINE_API bool Matches (const FRootMotionSource *Other) const
 
virtual ENGINE_API bool MatchesAndHasSameState (const FRootMotionSource *Other) const
 
virtual ENGINE_API bool UpdateStateFrom (const FRootMotionSource *SourceToTakeStateFrom, bool bMarkForSimulatedCatchup=false)
 
virtual ENGINE_API bool IsActive () const
 
virtual ENGINE_API void SetTime (float NewTime)
 
virtual ENGINE_API void CheckTimeOut ()
 
virtual ENGINE_API void PrepareRootMotion (float SimulationTime, float MovementTickTime, const ACharacter &Character, const UCharacterMovementComponent &MoveComponent)
 
virtual ENGINE_API bool NetSerialize (FArchive &Ar, UPackageMap *Map, bool &bOutSuccess)
 
virtual ENGINE_API UScriptStructGetScriptStruct () const
 
virtual ENGINE_API FString ToSimpleString () const
 
virtual void AddReferencedObjects (class FReferenceCollector &Collector)
 

Public Attributes

uint16 Priority
 
uint16 LocalID
 
FName InstanceName
 
float StartTime
 
float CurrentTime
 
float PreviousTime
 
float Duration
 
FRootMotionSourceStatus Status
 
FRootMotionSourceSettings Settings
 
ERootMotionAccumulateMode AccumulateMode
 
bool bInLocalSpace
 
bool bNeedsSimulatedCatchup
 
bool bSimulatedNeedsSmoothing
 
FRootMotionMovementParams RootMotionParams
 
FRootMotionFinishVelocitySettings FinishVelocityParams
 

Detailed Description

Generalized source of Root Motion to a CharacterMovementComponent.

Has priorities and different accumulation modes (override, additive, set, ignore).

RootMotionSources are accumulated from highest priority to lowest, once all values are "finalized" (meaning no more accumulation to those values), root motion accumulation is finished. Having all of translation and rotation in a transform being overridden during root motion accumulation means that CharacterMovementComponent Phys*() functions no longer need to CalcVelocity() since it'll just get overridden anyway.

Some example source possibilities: Full Animation Root Motion (matching only form of root motion we've supported historically):

  • Overrides all translation axes or rotation or both
  • Very High priority so it gets applied first and since it is override no other RootMotionSources have an influence that are lower priority
  • Scale on translation and/or rotation is set to 1 to match animation 1 for 1
  • Provides local space transform (character-orientation relative)
  • End result: Same as before - overrides velocity/rotation to values in AnimMontage
  • But can now scale individual translation axes if desired, or instead of override can use "set" to allow other additive sources of root motion to be applied on top of the animation root motion (modify velocity to home root motion melee attacks, etc.)

Jump pad volumes that work during animation root montage attacks

  • Constant velocity modification Z up, additive and high priority
  • Attack/melee animation root motion uses "set" instead of "override" to allow other sources
  • Animation root motion is applied, then the Z up additive of this source is so you are affected by the jump pad

Attack/melee homing

  • Additive, lower priority so it gets applied after any animation/significant root motion
  • World space, sourced by logic modifying velocity to go towards nearby enemies
  • Could point to a UAbilityTask node from the GameplayAbilities system

Character movement controlled by splines/curves in-editor instead of requiring animation tweaks

  • Same as animation root motion but source from spline/curve data

Constructor & Destructor Documentation

◆ FRootMotionSource()

FRootMotionSource::FRootMotionSource ( )

◆ ~FRootMotionSource()

virtual FRootMotionSource::~FRootMotionSource ( )
inlinevirtual

Member Function Documentation

◆ AddReferencedObjects()

◆ CheckTimeOut()

void FRootMotionSource::CheckTimeOut ( )
virtual

Checks if this source has timed out and marks for removal if necessary

◆ Clone()

FRootMotionSource * FRootMotionSource::Clone ( ) const
virtual

◆ GetDuration()

float FRootMotionSource::GetDuration ( ) const
Returns
the Duration - the length of this root motion - < 0 for infinite (to be removed manually)

◆ GetScriptStruct()

◆ GetStartTime()

float FRootMotionSource::GetStartTime ( ) const
Returns
the StartTime - time this source should start (in character movement client time)

◆ GetTime()

float FRootMotionSource::GetTime ( ) const
Returns
the CurrentTime - amount of time elapsed so far for this source

◆ IsActive()

bool FRootMotionSource::IsActive ( ) const
virtual

True when this RootMotionSource should be affecting root motion

◆ IsStartTimeValid()

bool FRootMotionSource::IsStartTimeValid ( ) const
Returns
whether the start time has been set

◆ IsTimeOutEnabled()

bool FRootMotionSource::IsTimeOutEnabled ( ) const
virtual
Returns
whether this source will be removed when CurrentTime reaches Duration

Reimplemented in FRootMotionSource_JumpForce.

◆ Matches()

bool FRootMotionSource::Matches ( const FRootMotionSource Other) const
virtual
Returns
Whether this is the same RootMotionSource as Other. This is used for networking when clients receive RootMotionSource data from the server and need to decide which local RootMotionSource to compare and apply the corrections to. This is required due to RootMotionSources in general being added independently on server and clients, not needing to know about each other by default.

For well-networked RootMotionSources, any given FRootMotionSource child class could implement their own unique ID and simply use that in the Matches check. This "heuristic-style" default was chosen to simplify addition of new RootMotionSources, and assumes that in a networked setting a given RootMotionSource won't be applied many times in a given frame by the same instigator to the same target with the exact same parameters.

Guaranteed uniqueness would also require a strict application order ("RootMotionSources can only be added on Authority") or a prediction-based setup ("Apply on Autonomous and Simulated predictively, then apply on Authority and confirm, and if Authority doesn't confirm remove them"). We avoid that synchronization complexity for now.

See UCharacterMovementComponent::ConvertRootMotionServerIDsToLocalIDs

Should be overridden by child classes, as default implementation only contains basic equivalency checks

Reimplemented in FRootMotionSource_ConstantForce, FRootMotionSource_RadialForce, FRootMotionSource_MoveToForce, FRootMotionSource_MoveToDynamicForce, and FRootMotionSource_JumpForce.

◆ MatchesAndHasSameState()

bool FRootMotionSource::MatchesAndHasSameState ( const FRootMotionSource Other) const
virtual

◆ NetSerialize()

◆ PrepareRootMotion()

void FRootMotionSource::PrepareRootMotion ( float  SimulationTime,
float  MovementTickTime,
const ACharacter Character,
const UCharacterMovementComponent MoveComponent 
)
virtual

Generates the RootMotion for this Source, can be used for both "live" generation or for playback (client prediction correction, simulated proxies, etc.)

Examples:

  • Animation RootMotionSources use Time as track time into AnimMontage and extract the root motion from AnimMontage chunk of time (Position,Position+DeltaTime)
  • ConstantForce source uses Time as the time into the application so if its duration ends halfway through the frame it knows how much root motion it should have applied
  • Spline/curve-based sources use Time for knowing where on spline/curve to extract from
    Parameters
    SimulationTimeHow far forward in time to simulate root motion
    MovementTickTimeHow much time the movement is going to take that this is being prepared for

Reimplemented in FRootMotionSource_ConstantForce, FRootMotionSource_RadialForce, FRootMotionSource_MoveToForce, FRootMotionSource_MoveToDynamicForce, and FRootMotionSource_JumpForce.

◆ SetTime()

void FRootMotionSource::SetTime ( float  NewTime)
virtual

Set the CurrentTime of this source. Use this setter so that sources based on duration can get correctly marked for end

Reimplemented in FRootMotionSource_MoveToForce, and FRootMotionSource_MoveToDynamicForce.

◆ ToSimpleString()

◆ UpdateStateFrom()

bool FRootMotionSource::UpdateStateFrom ( const FRootMotionSource SourceToTakeStateFrom,
bool  bMarkForSimulatedCatchup = false 
)
virtual

Mainly for server correction purposes - update this Source's state from another's, usually the authoritative state from the server's version of the Source

Parameters
bMarkForSimulatedCatchupsets the source for needing to "catch up" to current state next Prepare
Returns
Whether the update was sucessful or not. Note that failure to update denotes a complete failure, and the Source will then be marked for removal. We need to remove since we don't have a way of reverting partial updates depending on where the update failed.

Reimplemented in FRootMotionSource_ConstantForce, FRootMotionSource_RadialForce, FRootMotionSource_MoveToForce, FRootMotionSource_MoveToDynamicForce, and FRootMotionSource_JumpForce.

Member Data Documentation

◆ AccumulateMode

ERootMotionAccumulateMode FRootMotionSource::AccumulateMode

Accumulation mode for this source (whether or not to additively apply this root motion or override completely)

◆ bInLocalSpace

bool FRootMotionSource::bInLocalSpace

True when this RootMotionSource is contributing local space accumulation (false for world space)

◆ bNeedsSimulatedCatchup

bool FRootMotionSource::bNeedsSimulatedCatchup

True when this RootMotionSource has been marked for simulated catchup - this Simulated version of the Source needs to catch up to where it was before being corrected by authoritative version.

◆ bSimulatedNeedsSmoothing

bool FRootMotionSource::bSimulatedNeedsSmoothing

True when this RootMotionSource is running on a SimulatedProxy and has marked itself as needing location/rotation smoothing. This smoothing logic is what runs whenever the SimulatedProxy receives a replication update from the server (SimulatedTick in CharacterMovementComponent, see bCorrectedToServer and SmoothCorrection), this flag allows the RootMotionSource to signal to the CMC that a change was done significant enough that needs smoothing.

◆ CurrentTime

float FRootMotionSource::CurrentTime

Time elapsed so far for this source

◆ Duration

float FRootMotionSource::Duration

The length of this root motion - < 0 for infinite (to be removed manually)

◆ FinishVelocityParams

FRootMotionFinishVelocitySettings FRootMotionSource::FinishVelocityParams

Finish Velocity Parameters

◆ InstanceName

FName FRootMotionSource::InstanceName

This name allows us to find the source later so that we can end it.

◆ LocalID

uint16 FRootMotionSource::LocalID

ID local to this client or server instance. Used for matching up FRootMotionSources between SavedMoves and allow a mapping between server LocalIDs and client LocalIDs for correction/comparison

◆ PreviousTime

float FRootMotionSource::PreviousTime

The last Time entry we had before the last SetTime() - used for simulated catchup

◆ Priority

uint16 FRootMotionSource::Priority

Priority of this source relative to other sources - higher number being the highest priority/first applied.

◆ RootMotionParams

FRootMotionMovementParams FRootMotionSource::RootMotionParams

Root Motion generated by this Source

◆ Settings

FRootMotionSourceSettings FRootMotionSource::Settings

Settings of this source

◆ StartTime

float FRootMotionSource::StartTime

Time this source should start (in character movement client time) This is used to handle cases of inconsistent tick times (ServerMoves ticking for 1 second when root motion should have only applied for the last 0.1 seconds, or root motion source ending halfway through a 0.5 second tick)

◆ Status

FRootMotionSourceStatus FRootMotionSource::Status

Status of this source


The documentation for this struct was generated from the following files: