Search Unity

Third Party Network Animator not syncing - Mirror Networking

Discussion in 'Multiplayer' started by NikolayHadzhiev, Jun 1, 2023.

  1. NikolayHadzhiev

    NikolayHadzhiev

    Joined:
    Jan 20, 2018
    Posts:
    4
    I have a character whose Animator and Network Animator are set after instantiation by the network manager in this function
    Code (CSharp):
    1. public void ReplacePlayer(NetworkConnectionToClient conn, uint characterID, bool keepPosition)
    2.     {
    3.         GameObject oldPlayer = conn.identity.gameObject;
    4.         CharacterSelect selectedCharacter = GetCharacterByID(characterID);
    5.  
    6.         GameObject newPlayer = selectedCharacter.GetController();
    7.         NetworkServer.ReplacePlayerForConnection(conn, Instantiate(newPlayer), false);
    8.  
    9.         conn.identity.GetComponent<AnimatorSync>().SetAnimatorByID(characterID);    // sets the animator and network animator
    10.         if (keepPosition) conn.identity.GetComponent<NetworkTransform>().RpcTeleport(oldPlayer.transform.position);
    11.  
    12.         Destroy(oldPlayer, 0.1f);
    13.         OnCharacterChosen(conn);
    14.     }
    All the animation works locally, but none of it is synced through the network. The animation is handled by the client. Here's what the components look like:
    upload_2023-6-1_14-54-25.png
    And I also get this weird error constantly when there's a player in the scene: upload_2023-6-1_14-55-2.png
    Thanks a lot for your help!