MirrorNetworking / Mirror

#1 Open Source Unity Networking Library
https://mirror-networking.com
MIT License
5.21k stars 769 forks source link

NetworkTransformChild not working on the server #2619

Closed kronnect closed 3 years ago

kronnect commented 3 years ago

Describe the bug Character doesn't sync rotation correctly on the server. This is a rigged, animated, character which contains a NetworkIdentity, NetworkTransform and NetworkAnimator attached to the root plus a CharacterController and other control scripts. We also have a NetworkTransformChild on this root linked to a Spine bone so the character spine rotates when he looks upwards. When running on the server, the character position and rotation as well as the animation works correctly. However, it doesn't look upwards when in the client is rotating. Instead it flickers between looking forward and upward like if the animator and the NetworkTransformChild had some kind of race condition by which on some frames the NetworkTransformChild mandates and in other frames the animator does, producing a strange glitch/flickering in the spine rotation. We need the rotation to work correctly on the server because some bullets are spawned on the tip of the weapon. If the rotation is not correct, the server spawns bullets in wrong positions.

How to reproduce the issue, step by step Add a character to a scene and attach the same components explained above. Add a script that rotates the spine bone when pressing some keys or moving the mouse around. Start the server and connect from a client. Notice how in the client (which has authority), the character animation is correct (if it has an idle animation, it will play correctly while the rotation of the spine also works). However, if you look at the character on the server, it doesn't look correct.

Expected behavior Correct character animation and spine rotation on the server.

Desktop (please complete the following information):

MrGadget1024 commented 3 years ago

This definitely sounds like a fight between NTC and NA. They shouldn't be managing the same body parts. Animator should probably do it all in this case without NTC.

SoftwareGuy commented 3 years ago

In addition to MrGadget's suggestion above, what happens if a mask was used on the animator layer to prevent the arms moving via animation?

miwarnec commented 3 years ago

in discord someone mentioned changing NT update to lateupdate works

kronnect commented 3 years ago

We finally used this workaround: