Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Third Party Mirror Network Animation Issues

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

  1. QuickiSticki

    QuickiSticki

    Joined:
    Nov 18, 2020
    Posts:
    26
    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:
    26
    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
     
  5. Dev_Moona

    Dev_Moona

    Joined:
    Dec 12, 2019
    Posts:
    5
    How did you solve this?
     
    MuntyMcFly likes this.
  6. QuickiSticki

    QuickiSticki

    Joined:
    Nov 18, 2020
    Posts:
    26
    Honestly, this was a few months ago and I don't completely remember. I can tell you that my animator is still on a child GO, and the network animator is on the parent GO, but is using the child animator as its reference. I did end up moving that script to the parent GO instead of the child GO. That made it so I didn't need to reference the parent gameObject AND it made it so I could set the script controlling my animations as a NetworkBehaviour script instead of MonoBehaviour. The code that I posted above, I have removed all bits for networkAnim. This is the same section as I posted above, but how it sits now, working perfectly fine:
    Capture.JPG
    Capture 1.JPG
    Capture 2.JPG

    Looking back, moving the script to the parent GO was probably the fix, but I cannot remember exactly. :(

    If you still need help, and what I showed does not clear any of it up, I am happy to talk and help more! Just let me know. :)
     
    EinfachNurToni likes this.
  7. EinfachNurToni

    EinfachNurToni

    Joined:
    Aug 17, 2020
    Posts:
    1
    How have you been able to have multiple Network Identities in one Prefab? And if you just referenced to the root one, how have you done this?
     
    Omen09 likes this.