FRootMotionSource

Generalized source of Root Motion to a CharacterMovementComponent.

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

Engine

Header

/Engine/Source/Runtime/Engine/Classes/GameFramework/RootMotionSource.h

Include

#include "GameFramework/RootMotionSource.h"

Syntax

struct FRootMotionSource

Remarks

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

Variables

Name Description

Public variable

ERootMotionAccu...

 

AccumulateMode

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

Public variable

bool

 

bInLocalSpace

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

Public variable

bool

 

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.

Public variable

float

 

CurrentTime

Time elapsed so far for this source

Public variable

float

 

Duration

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

Public variable

FRootMotionFini...

 

FinishVelocityParams

Finish Velocity Parameters

Public variable

FName

 

InstanceName

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

Public variable

uint16

 

LocalID

ID local to this client or server instance.

Public variable

float

 

PreviousTime

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

Public variable

uint16

 

Priority

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

Public variable

FRootMotionMove...

 

RootMotionParams

Root Motion generated by this Source

Public variable

FRootMotionSour...

 

Settings

Settings of this source

Public variable

float

 

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)

Public variable

FRootMotionSour...

 

Status

Status of this source

Constructors

Name Description

Public function

FRootMotionSource()

Destructors

Name Description

Public function Virtual

~FRootMotionSource()

Functions

Name Description

Public function Virtual

void

 

AddReferencedObjects

(
    FReferenceCollector& Collector
)

Public function Virtual

void

 

CheckTimeOut()

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

Public function Virtual Const

FRootMotionS...

 

Clone()

Public function Const

float

 

GetDuration()

Public function Virtual Const

UScriptStruc...

 

GetScriptStruct()

Public function Const

float

 

GetStartTime()

Public function Const

float

 

GetTime()

Public function Virtual Const

bool

 

IsActive()

True when this RootMotionSource should be affecting root motion

Public function Const

bool

 

IsStartTimeValid()

Public function Virtual Const

bool

 

IsTimeOutEnabled()

Public function Virtual Const

bool

 

Matches

(
    const FRootMotionSource* Other
)

For well-networked RootMotionSources, any given FRootMotionSource child class could implement their own unique ID and simply use that in the Matches check.

Public function Virtual Const

bool

 

MatchesAndHasSameState

(
    const FRootMotionSource* Other
)

Checks that it Matches() and has the same state (time, track position, etc.)

Public function Virtual

bool

 

NetSerialize

(
    FArchive& Ar,
    UPackageMap* Map,
    bool& bOutSuccess
)

Public function Virtual

void

 

PrepareRootMotion

(
    float SimulationTime,
    float MovementTickTime,
    const ACharacter& Character,
    const UCharacterMovementComponent&...
)

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

Public function Virtual

void

 

SetTime

(
    float NewTime
)

Set the CurrentTime of this source.

Public function Virtual Const

FString

 

ToSimpleString()

Public function Virtual

bool

 

UpdateStateFrom

(
    const FRootMotionSource* Sourc...,
    bool bMarkForSimulatedCatchup
)

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

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss