Short version: How can be animations with root motion synchronized in multiplayer (or networking in general) so the animations are fluent and synchronized as much as possible?
Long version: Movement of characters in my project is controlled by root motion of animation, so my code calculate speed and angular speed from user input: user clicks on scene, NavMeshAgent calculates path and result is used to navigate the character. Each player has it’s own character and I want to synchronize their movement using networking.
- It’s not authoritative server networking: each client is responsible for moving their character.
- When a character receives new destination from user, first few corners from the path are sent to other players - when first destination is reached, next corner is sent, so all players keeps track of character’s path.
- Each client calculates movement of the character from the path and animate it accordingly.
- When the character is too long away from expected position (expected = on it’s “home” client), it’s moved there and rotated accordingly.
But this is not working well:
- According question 589291 animations are calculated in Update() and not FixedUpdate() (and then interpolated) which causes following:
- When fps on clients is different, character makes different stepd and turnd on corners which makes animation different and their movement too. It’s all out of sync.
- In other words, unlike physics, animation movement (root motion) is apparently not predictable.
So my question is: is there a way to prevent this, or root motion is unusable for multiplayer (making it singleplayer-only feature)?
Notes:
- From my description it should be clear I use movement prediction. Reason is simple: when I “just” synchronized animation and position, it was everything but fluent, especially in corners where speed and angular speed is changed in much bigger rate then 15 updates per seconds which is default update rate for networking. Of course I could change the rate, but I need to think about bad quality connection (which is not my whim, but I cannot write more).
- Everything is tested on single PC so the problem is not from bad connection.
- For now I’m using animation and models from Stealth project. This is for testing only, of course.
Did you get any insight on this? I am facing a similar problem.
– AxelMGarcia