Navigation
API > API/Runtime > API/Runtime/Engine
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
| Name | FRootMotionSource |
| Type | struct |
| Header File | /Engine/Source/Runtime/Engine/Classes/GameFramework/RootMotionSource.h |
| Include Path | #include "GameFramework/RootMotionSource.h" |
Syntax
USTRUCT ()
struct FRootMotionSource : public FRootMotionSourceFixLayout
Inheritance Hierarchy
- FRootMotionSourceFixLayout → FRootMotionSource
Derived Classes
FRootMotionSource derived class hierarchy
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FRootMotionSource() |
GameFramework/RootMotionSource.h |
Destructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual ~FRootMotionSource() |
GameFramework/RootMotionSource.h |
Variables
Public
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| AccumulateMode | ERootMotionAccumulateMode | Accumulation mode for this source (whether or not to additively apply this root motion or override completely) | GameFramework/RootMotionSource.h | |
| bInLocalSpace | bool | True when this RootMotionSource is contributing local space accumulation (false for world space) | GameFramework/RootMotionSource.h | |
| bNeedsSimulatedCatchup | bool | 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. | GameFramework/RootMotionSource.h | |
| bSimulatedNeedsSmoothing | bool | True when this RootMotionSource is running on a SimulatedProxy and has marked itself as needing location/rotation smoothing. | GameFramework/RootMotionSource.h | |
| CurrentTime | float | Time elapsed so far for this source | GameFramework/RootMotionSource.h | |
| Duration | float | The length of this root motion - < 0 for infinite (to be removed manually) | GameFramework/RootMotionSource.h | |
| FinishVelocityParams | FRootMotionFinishVelocitySettings | Finish Velocity Parameters | GameFramework/RootMotionSource.h |
|
| InstanceName | FName | This name allows us to find the source later so that we can end it. | GameFramework/RootMotionSource.h | |
| LocalID | uint16 | ID local to this client or server instance. | GameFramework/RootMotionSource.h | |
| PreviousTime | float | The last Time entry we had before the last SetTime() - used for simulated catchup | GameFramework/RootMotionSource.h |
|
| Priority | uint16 | Priority of this source relative to other sources - higher number being the highest priority/first applied. | GameFramework/RootMotionSource.h | |
| RootMotionParams | FRootMotionMovementParams | Root Motion generated by this Source | GameFramework/RootMotionSource.h |
|
| Settings | FRootMotionSourceSettings | Settings of this source | GameFramework/RootMotionSource.h |
|
| StartTime | float | 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) | GameFramework/RootMotionSource.h |
|
| Status | FRootMotionSourceStatus | Status of this source | GameFramework/RootMotionSource.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual void AddReferencedObjects
(
FReferenceCollector& Collector |
GameFramework/RootMotionSource.h | ||
virtual void CheckTimeOut() |
Checks if this source has timed out and marks for removal if necessary | GameFramework/RootMotionSource.h | |
virtual FRootMotionSource * Clone() |
GameFramework/RootMotionSource.h | ||
float GetDuration() |
GameFramework/RootMotionSource.h | ||
virtual UScriptStruct * GetScriptStruct() |
GameFramework/RootMotionSource.h | ||
float GetStartTime() |
GameFramework/RootMotionSource.h | ||
float GetTime() |
GameFramework/RootMotionSource.h | ||
virtual bool IsActive() |
True when this RootMotionSource should be affecting root motion | GameFramework/RootMotionSource.h | |
bool IsStartTimeValid() |
GameFramework/RootMotionSource.h | ||
virtual bool IsTimeOutEnabled() |
GameFramework/RootMotionSource.h | ||
virtual 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. | GameFramework/RootMotionSource.h | |
virtual bool MatchesAndHasSameState
(
const FRootMotionSource* Other |
Checks that it Matches() and has the same state (time, track position, etc.) | GameFramework/RootMotionSource.h | |
virtual bool NetSerialize
(
FArchive& Ar, |
GameFramework/RootMotionSource.h | ||
virtual void PrepareRootMotion
(
float SimulationTime, |
Generates the RootMotion for this Source, can be used for both "live" generation or for playback (client prediction correction, simulated proxies, etc.) | GameFramework/RootMotionSource.h | |
virtual void SetTime
(
float NewTime |
Set the CurrentTime of this source. | GameFramework/RootMotionSource.h | |
virtual FString ToSimpleString() |
GameFramework/RootMotionSource.h | ||
virtual bool UpdateStateFrom
(
const FRootMotionSource* SourceToTakeStateFrom, |
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 | GameFramework/RootMotionSource.h |