Root Motion Over Network - How Its Done

[Sorry for taking so long to respond.]
As far as replicating root motion over network with Unreal, it absolutely is supported and can be done.
To understand how it works, first consider the problem of just synchronizing animations.

Lets say we have a walk/run/blend animation. The blend factor is based on a variable called speed.
The AnimationBP relies on the Speed variable in the CharacterBP. It reads this every frame in UpdateAnimation.
UpdateAnimation is called, reads the speed variable, and determines the blended pose for the BlendSpace based on the value in Speed.

Now to synchronize the animations over the network, you have to synchronize the Speed variable by replicating it. This keeps all the animations relatively in sync - however, due to network latency, there will always be a few frames that dont match exactly. But in general over time, the same walk/run/idle will end up playing on the client and the server.

Now consider root motion. The root bone transform from the current pose is applied directly to the characters capsule.
Thus the animation (whether playing on client or server) will move the pawn.

A common source of confusion is that you need to replicate this motion.
You DO NOT replicate the motion.
You replicate the variables that control animation state, and let the animation (independently playing on all machines) dictate the motion.

If the animations were perfectly in sync, then the positions would perfectly match.
They are not in sync, so their is a reconciliation process used to match their position over time( just as it is used for non root-motion).

Without root motion, you typically replicate velocity or some other state and then rely on client-side prediction to determine position between network updates.
With root motion, you let the animation playing determine position between network updates.

In both scenarios, you rely on position reconciliation to update the positions based on the most recent location update.
(If you are interested in looking at the reconciliation code specifically for root motion on the CharacterMovementCompenent, it is in UCharacterMovementComponent::ClientAdjustRootMotionSourcePosition_Implementation().)

It is important to note that Root Motion may not work in your situation- it depends on what you are doing whether it makes sense for you.

Given the confusion and interest, I will try to record a short tutorial and post it here.

3 Likes