Search Unity

  1. We have added sub-forums for the experimental MLAPI and Unity Transport Package. Please use the new forums to discuss related topics.
    Dismiss Notice

Resolved Mirror Network Animation Issues

Discussion in 'Multiplayer' started by QuickiSticki, May 6, 2021.

  1. QuickiSticki

    QuickiSticki

    Joined:
    Nov 18, 2020
    Posts:
    14
    Hello!

    So I am converting my game from single player to multiplayer. All of my animations work great locally, but I cannot find how to correctly set them up for Mirror networking. I have assigned the Network Identity and NetworkAnimator to my parent gameObject, however my animator is on a child gameObject. Now, multiplayer characters can see each other moving around just fine, but no animations are being played over the network.

    Capture.PNG

    My first question is does my Network Animator and my animator need to be on the same GO? The Network Animator makes you manually reference an animator, which leads me to think no, they can be on separate GO's. Otherwise they could just pull the local GO animator, if they had to be on the same object.

    My second question would be about referencing and syncing the animator in code to the Network animator. Assuming that they do not have to be on the same GO, I get a lot of errors when trying to reference the Network Animator from the animator's script. How do I reference the Network Animator if my animation script is on a different GO? I am limited because I cannot add a Network ID to the child GO, so I cannot make the animation script into a NetworkBehaviour instead of MonoBehaviour. I can however set it to "using Mirror;". Also, I cannot use GetComponent<>(); to get the NetworkAnimator. Using the code "networkAnim = playerCharacterPrefab.GetComponent<NetworkAnimator>()" I get the following error:
    Capture 3.PNG

    Capture 2.PNG

    If I cannot declare the networkAnim as an Animator, what should I declare it as?

    If anybody can help, I would very much appreciate it!
     
    Last edited: May 6, 2021
  2. EmeraldDevelopment

    EmeraldDevelopment

    Joined:
    Nov 18, 2020
    Posts:
    2
    Alright, so your second questions answer is where your creating the variable, set that to NetworkAnimator. You shouldn't even have to do anything in code unless your using a trigger. Just go to our player and assign network animator. For your first question, I will get back once I've tried it to see, as I am having the same issue. This could be an answer to your question and mine :)
     
  3. EmeraldDevelopment

    EmeraldDevelopment

    Joined:
    Nov 18, 2020
    Posts:
    2
    It doesn't seem to matter, the answer to your first question is that they can be separate, happy I could help!
     
  4. QuickiSticki

    QuickiSticki

    Joined:
    Nov 18, 2020
    Posts:
    14
    I have everything working great now. Let me know if you are still having either of these issues and I will see if I can help you with them. :D
     
unityunity