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
- 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.