com.unity.netcode.gameobjects icon indicating copy to clipboard operation
com.unity.netcode.gameobjects copied to clipboard

Animations do not Sync when using Client Network Transform from Samples

Open FSKiller opened this issue 4 years ago • 21 comments

Describe the bug When installing and using the Sample Client Network Transform the Network animator will stop syncing the animator values and the remote Animations from Player B will not play in Player A's screen.

To Reproduce Steps to reproduce the behavior:

  1. Install Netcode for Gameobjects
  2. Install Sample Client Network Transform
  3. Have an Animator with Animations
  4. In the "Player" add the components: NetworkObject, ClientNetWork Transform and Network Animator
  5. Launch a Client and Host/Server
  6. Watch the Animator Component from the remote object not syncing the Variables nor the Animations.

Actual outcome Remote Animations do not play in local clients and Vice-Versa.

Expected outcome The Animations should play in local clients and remote clients and the animatiors should be synced.

Environment (please complete the following information):

  • OS: Windows 10
  • Unity Version: 2021.1.25f1
  • Netcode Version: 1.0.0

Additional info -This issue was not present in MLAPI 0.1.0

FSKiller avatar Oct 23 '21 18:10 FSKiller

Same issue :( ! (Animator parameters not synced)

Tivise avatar Oct 23 '21 18:10 Tivise

For me, it is not working even when using the regular NetworkTransform. I'm on 1.0.0-pre.2.

joaoborks avatar Oct 23 '21 21:10 joaoborks

I just found out that using the Boss Room Network Animator works (sort of). It does not actively sync as it was supposed to, but it's a start.

joaoborks avatar Oct 23 '21 21:10 joaoborks

Managed to get Anims Working by using RPC's to set Anims params, but this should not be needed.

FSKiller avatar Oct 23 '21 23:10 FSKiller

Seems like it's fixed in master https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/pull/1327

aazzolini avatar Oct 23 '21 23:10 aazzolini

it's not, i tried both master and devop 1.0.0 pre3 none work

FSKiller avatar Oct 24 '21 00:10 FSKiller

@FSKiller the way I made it work is actually copying the code of NetworkAnimator into my own MyNetworkAnimator and commenting out those "if (valueInt != oldValue)" statements in WriteParameters

aazzolini avatar Oct 24 '21 23:10 aazzolini

As Luke said on Discord their new implementation is Server Authoritive, i managed to get them working too, but i used Rpc's to call the values. This is a pain if you want a Client Authoritive Game....

FSKiller avatar Oct 25 '21 12:10 FSKiller

Added to the backlog as MTT-1565

will-mearns avatar Oct 29 '21 16:10 will-mearns

I have the same issue. @aazzolini's solution of making a new NetworkAnimator with the if statements commented out caused some animations to be synched, but only certain transitions (for example into running, but not back into standing still). It's only one way too: the client gets to see some of the animations of the host, but the host sees none of the client.

daalen avatar Nov 02 '21 07:11 daalen

As Luke said on Discord their new implementation is Server Authoritive, i managed to get them working too, but i used Rpc's to call the values. This is a pain if you want a Client Authoritive Game....

Many indie projects are better off client authoritative. Less headaches in general, cheating isn't really a consideration, all that matters is to finish the game and get players.

Hopefully they support more client auth stuff, not just server or do it yourself.

LaserYGD avatar Nov 02 '21 11:11 LaserYGD

As Luke said on Discord their new implementation is Server Authoritive, i managed to get them working too, but i used Rpc's to call the values. This is a pain if you want a Client Authoritive Game....

@will-mearns if this is the case can we please update the documentation (https://docs-multiplayer.unity3d.com/docs/components/networkanimator) that it won't work with clients setting params on the animator? It seems to imply that all you need to do is add a NetworkAnimator and you're good to go. Spent quite a few hours debugging the NetworkAnimator script only to find that it may actually be a bug?

Let me know if I misunderstood this. Thanks!

Shivang44 avatar Dec 26 '21 05:12 Shivang44

Any news on this, maybe an approximate date? It is basically useless if you use an asset that does all the animations if they can't be synced.

MiTschMR avatar Jan 18 '22 20:01 MiTschMR

My game is client-sided but I'm now facing this issue as well. And It'll be problematic to switch to server authoritative due to lag issues.

Especially since NGO doesn't have client prediction.

On Tue, Jan 18, 2022 at 11:19 PM MiTschMR @.***> wrote:

Any news on this, maybe an approximate date? It is basically useless if you use an asset that does all the animations if they can't be synced.

— Reply to this email directly, view it on GitHub https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/1348#issuecomment-1015801607, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANGM4YU5DOS2ZGOUB2GIXXLUWXDOTANCNFSM5GSRNQVA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: <Unity-Technologies/com.unity.netcode.gameobjects/issues/1348/1015801607@ github.com>

LaserYGD avatar Jan 19 '22 05:01 LaserYGD

What I found out using 1.0 pre-5 is that if the Player you are controlling is instantiated on a Host, the animation sync happens if the NetworkAnimator component has the checkboxes checked. However, if you are a simple client, it doesn't happen because it is server authoritative. How would you guys do it if an asset you own has a player component that handles all the input via its own code and can't be changed without major refactoring? In my opinion there should be a checkbox or something similar to let the clients control the movement if checked. This way you can cover both easily with a single click and focus on the interactive part of the game (which is easily possible to control via the server).

MiTschMR avatar Feb 01 '22 15:02 MiTschMR

The network animator has been reworked with 1.0 pre-6 and now looks differently in the inspector, it does not show checkboxes anymore. Is there internal work being done or what was the reason for it?

MiTschMR avatar Mar 13 '22 22:03 MiTschMR

Ok, i just found out about this. I'm currently using the ClientNetworkTransform and i was trying to make the Animator work without luck.

Hoping this can get updated.

Ator9 avatar Apr 30 '22 00:04 Ator9

https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/pull/1946

Should fix this. Can you confirm ?

jeffreyrainy avatar May 25 '22 17:05 jeffreyrainy

Still not fixed. Players stay in idle animation and slide across the map.

As a temp fix i've been using RPC's to set the animator values, and this seems to work just fine at the cost of more network traffic.

FSKiller avatar Jun 01 '22 15:06 FSKiller

Create this script and then remove the NetworkAnimator and add ClientNetworkAnimator

     public class ClientNetworkAnimator : NetworkAnimator
     {
         protected override bool OnIsServerAuthoritative() => false;
     }

DevinWatson avatar Aug 12 '22 03:08 DevinWatson

@DevinWatson This isn't working for me. It enables the animations on the server but not on other clients.

ChadGatling avatar Aug 12 '22 21:08 ChadGatling

@ChadGatling I did apply some fixes just recently to NetworkAnimator that are now in the develop branch that were not synchronizing if there were 2 clients so you might try your project with the develop branch and see if the fixes I applied resolve your issue. These fixes will be included in the next update.

If what is currently in the develop branch does not solve your issue, could you provide a project so I can try to replicate it on my end?

NoelStephensUnity avatar Sep 30 '22 01:09 NoelStephensUnity

@NoelStephensUnity I am trying to verify this but I am getting a bunch of unrelated errors after updating to 1.1.0 and even just 1.0.2

ChadGatling avatar Oct 06 '22 13:10 ChadGatling

@ChadGatling could you share the errors that you are getting? I might be able to assist you with those.

NoelStephensUnity avatar Oct 06 '22 15:10 NoelStephensUnity

@NoelStephensUnity

Here is the first error I get with 1.1.0 as a client trying to connect to my server.

image removed

The server is seeing the client connect but then I get a handshake timeout. Then the server disconnects the client.

image removed

Thanks for looking.

ChadGatling avatar Oct 06 '22 20:10 ChadGatling

@ChadGatling What version of Unity are you using? There was a recent update to make NetworkVariables handle managed types and this requires the most recent version of Unity (or higher) to use the current develop branch: 2021.3.11f1 LTS 2020.3.40f1 LTS 2022.1.19f1

As well, if you want to use a specific branch you can update your Packages\manifest.json file with something like this for com.unity.netcode.gameobjects:

    "com.unity.netcode.gameobjects": "https://github.com/Unity-Technologies/com.unity.netcode.gameobjects.git?path=com.unity.netcode.gameobjects#develop",
    "com.unity.transport": "1.3.0",

(I included the most recent version of unity transport in there too)

This can be useful if you want to make sure you have the most recent version of a specific branch without having to download and point to the specific directory etc.

If you were using an earlier version of Unity, let me know if updating to the more recent version resolves these error messages for you?

NoelStephensUnity avatar Oct 06 '22 21:10 NoelStephensUnity

@NoelStephensUnity I updated my editor to 2021.3.11f1 and I am still getting the same issues

ChadGatling avatar Oct 06 '22 23:10 ChadGatling

@NoelStephensUnity The previous still applies and I also tried it with Netcode for GameObjects 1.0.2 and on the server on player connect I am getting

image

and on the client right after connecting I get

image

The client actually connects but the network transform is not working. The animator works but the character remains in place. I am using client network transform and animator.

Edit: Seems like 2021.3 requires Shader graph 12.1.7 which breaks all my shader graph shaders so something is really messed up.

ChadGatling avatar Oct 07 '22 12:10 ChadGatling

@ChadGatling Ahh...well at least the errors you are getting are different than before and so updating did help resolves those errors. It looks like you are still using the 1.0.0-pre.3 version of ClientNetworkTransform. Replace that with the updated version of ClientNetworkTransform. That should resolve the new errors you are getting.

NoelStephensUnity avatar Oct 07 '22 15:10 NoelStephensUnity

@NoelStephensUnity So this version of ClientNetworkTransform is for the 1.0.2 version of Netcode for gameobjects? Or for 1.1.0? And all of this is to be used with Unity 2021.3.11? I can't seem to find the info about what version requires what version

ChadGatling avatar Oct 07 '22 19:10 ChadGatling