Has anyone played with the NetworkAnimator?

The documentation doesn’t show an example on how this work, unless I am missing something, I have been searching through them. I was just curious if anyone has got something working with this that they could share some insights maybe. It seems pretty straight forward like the NetworkTransform. I was not able to drag in the animator controller into the inspector slot for some reason, but was able to set the animator property for the NetworkAnimator in code to the players Animator component and that worked fine. When I “host” a server the local client on the host server does have his animations played/synced across all connected clients but when I connect other clients their animations are not played/synced on any other client or the server, so I feel like I am missing something obvious. The base idle animation does seem to play for all clients, but instead of walking/running/jumping animation the player just moves with no animation when it is not the player hosting the game. Also when just running a stand alone server and connecting clients no animations played across the network. I don’t seem to understand how the NetworkAnimator api functions work. The SetTrigger function seems straight forward but the animation setup I am using does not use triggers. So I was just hoping someone could share what they did.

I’ve used it. You need to set it up in a live GameObject, not in a prefab (eg drag your prefab into scene, set it up, then update prefab). Once you drag the animator into it, you’ll see a list of fields to sync. It works fairly well, though I’ve had issues with the animator values not propagating to non-server local players. I think this is related to issues with NetworkTransform and player authoritative movement causing corruption (weird, hard-to-define issue. I have a post here about it.) I imagine the issues I’ve seen with it will be fixed before too long. In the meantime, it should work fairly well for non-player objects. Sync period is 0.1s by default. Not sure if it’s changeable in code or not. It doesn’t do smoothing/interpolation, which would be a nice option for values used in blend trees, but I’m sure they’ll make it more robust in the future.

If you end up using it, I’d be interested to hear how it goes.

2 Likes

Thanks for the input. When putting the player in the scene I wasnt able to drag in the animator but I was able to place the player in the slot and its animator was automatically referenced in the inspector. The parameters in the animator were then exposed in the inspector. Even with checking these and updating the player prefab the situation did not change, I had the same network anim sync issues as before. I will try it with a non player character though like you said and see how that works out and report back. I tried to also set the animation parameters to auto send using the function in the api, just a shot in the dark, Im probably not using it right anyway. I also had the thought that it had something to do with the local player authority situation. After digging more I did notice that in the MsgType class there is options for Animation, AnimationParams and AnimationTrigger so maybe something needs to be done with registering handlers like with the other MsgTypes like Connect and AddPlayer that are used in the examples, that might explain some things. I will keep toying with it tonight and see if I come up with something. Im sure the Unity network guys will get us pointed in the right direction soon.

I’ve played with this some more. Non player objects seem to work like you said Bison. You mentioned a sync period? I dont see this option at all in the inspector if thats what you meant? I just see the anim controller params exposed. The model and animations I was using initially were from the Unity Asset pack, the 2D robot guy. Like I mentioned before the idle animation would play on the server and other clients but not the walking and crouching once the player was moving. When I would jump the “falling” animation as the remote player came back to the ground would sort of stutter or flicker on the server and other clients but not really play, so something was at least getting sent. I swapped out that player prefab for a single cube player with a single animation I created that just makes him spin around once with a trigger. The animation played on server and other clients with a stuttering/flickering also, but was at least triggered, but not in sync or smooth at all. So I tried a zombie prefab I have and used him as the player object, his animations played but were not quite in sync. His walking animation plays in other windows, the stuttering/flickering kind of only happens when I start to move him at the same time, but thats more transform snapping to position then the animation not working maybe, not sure. But the animation itself is out of sync with what I observe in other windows, example… as he walk his steps are opposite footing, as in while the left foot is stepping forward on the client the right foot is going forward on server and other clients. All that said when I just spawn my zombie hordes from the server, as spawned non player objects, their animations are synced up nicely(walking steps in sync and attacking animations) across server and clients as they run after the players in the scene and chase them around(pretty fun). So the only issue I am really having currently is having the remote client players animations working as smooth as everything else animation wise on the network. Any ideas what Im probably doing wrong?

I too am trying to get this to work. So far no luck. I have done the above but I always get spammed this error:

ArgumentOutOfRangeException: Argument is out of range.
Parameter name: index
System.Collections.Generic.List`1[UnityEngine.Networking.NetworkClient].get_Item (Int32 index) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:633)
UnityEngine.Networking.NetworkAnimator.CheckSendRate () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkAnimator.cs:177)
UnityEngine.Networking.NetworkAnimator.FixedUpdate () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkAnimator.cs:95)

As well as my values not being synced at all over the network. I have tried this (and received the error) with the included Ethan animator from the Unity Samples. I have tried selecting and deselecting a multitude of the mecanim values to sync, even to sync none, with the same issue. Seems something about this animator is triggering it to think there is more or less values than in actual existence.

1 Like

I have never gotten an error of any sort to report. @Ghosthowl has info that might be more useful at least then