coherence doesn't replicate Animator state, but its parameters. Latency can create scenarios where different clients reproduce different animations. Take this into account when working with Animator Controllers that require precise timings.
Unity Animator's parameters are bindable out of the box, with the exception of triggers.
Triggers
Triggers can be invoked over the network using commands and events. Here's an example where we inform networked clients that we have played a jump animation:
usingUnityEngine;usingCoherence.Toolkit;usingSystem.Collections.Generic;publicclassJumpController:MonoBehaviour{staticList<CoherenceSync> instances =newList<CoherenceSync>();CoherenceSync coherenceSync;Animator animator;voidAwake() { coherenceSync =GetComponent<CoherenceSync>(); animator =GetComponent<Animator>(); }voidOnEnable() {instances.Add(coherenceSync); }voidOnDisable() {instances.Remove(coherenceSync); }voidUpdate() {if (!coherenceSync.isSimulated) {return; }if (Input.GetKeyDown(KeyCode.Space)) {MakePlayerJump(); } }voidMakePlayerJump() {animator.SetTrigger("Jump"); // TODO move your character upNotifyJumpOverNetwork(coherenceSync); } // bind to this method via the Bindings windowpublicvoidPlayJumpAnimation(CoherenceSync target) {var animator =target.GetComponent<Animator>();animator.SetTrigger("Jump"); }voidNotifyJumpOverNetwork(CoherenceSync whoJumped) {foreach (var s in instances) {if (!s || s == whoJumped) {continue; }s.SendCommand("JumpController.PlayJumpAnimation", whoJumped); } }}
Since we don't have support for events yet, here we use command broadcasting and entity references to notify other clients about our entity performing a jump.