4

My player character moves around the world using the Animator with root motion activated. Basically, the AI system sets the velocities on Animator, which in turn controls the Animation clips that control character motion. As this is a standard feature that ensures very realistic animation without noticable sliding, I thought this was a good idea ...until I added Network synchronization.

Synching the characters over the Network using NetworkTransform and NetworkAnimation causes those two components to conflict:

  • NetworkTransform moves the character to whichever position the host commands.
  • NetworkAnimator syncs the animation vars and plays the Animation clips as host instructs it to, while those Animation clips also apply root motion.

The result is precise (meaning the character reaches the exact target destination), but very stuttering movement (noticable jumps).

Removing NetworkTransform, the host and client instances of the characters desynchronize very quickly, meaning they will end up at different positions in the world when solely controlled by the timing-dependant Animator.

Removing NetworkAnimator, client instances won't play the same animations as the host, if any animations at all.

I tried keeping both Components while disabling root motion for the Animator (on client only). In that case however, NetworkTransform does not seem to interpolate at all. The character just jumps from synched position to synched position in steps of about 0.02 units. Same with rotation.

NetworkTransform is configured to "Sync Transform", as the character neither has a RigidBody nor a CharacterController. All other values are the defaults: sync rate of 9 (also tried higher values there), movement threshold of 0.001, snap threshold of 5, interpolate movement = 1.

How do I get fluent root motion based movement on the Network? I expected that to be a standard scenario...

Thomas Hilbert
  • 3,559
  • 2
  • 13
  • 33

1 Answers1

0

What you need is to disasble the Root Motion flag on non local instances but also to interpolate the rotation, not just the movement.

Moreover, an interpolation of 1 seems high, same as the thereshold of 5: those seem not realistic unless you are not using Unity standard where 1 unit = 1 meter. I would have a 25cm (0.25) interpolation for the movementand a 3 degrees for the rotation. The sync rate of 9 could be enough but in my experience it has to be recomputed based on the packet loss.