Search Unity

Network animator or how are you syncing animations?

Discussion in 'Multiplayer' started by TheLastVertex, Jun 18, 2019.

  1. TheLastVertex

    TheLastVertex

    Joined:
    Sep 30, 2015
    Posts:
    126
    I've been using the Network Animator for some basic animations without issue but recently started to implement more and came across some short comings.

    The following appear to work fine and sync without issue:
    Code (CSharp):
    1. NetworkAnimator.Animator.SetBool();
    2. NetworkAnimator.Animator.SetIntegerl();
    3. NetworkAnimator.Animator.SetFloat();
    The following however does nothing...
    Code (CSharp):
    1. NetworkAnimator.Animator.SetTrigger();
    But.... we have this alternative... or so I thought
    Code (CSharp):
    1. NetworkAnimator.SetTrigger();
    Using this instead does actually trigger the animation across the network but doesn't appear to auto set the trigger to false once it's done playing, so it plays continually? I found some old forum posts related to a similar issue that apparently was never fixed. I considering using booleans instead but was getting annoyed trying to find ways to disable something when you only want it to play once.

    As such I'm looking for ways to sync animations across the network using UNET. I'm curious if anyone has an alternative solutions they would recommend I look into first? Unless there is a known solution to the triggers issue.

    I'm leaning towards doing this manually with RPC's and handling what I can on the client, but would like to get some ideas of what others are doing before I dive too far into this.
     
  2. TheLastVertex

    TheLastVertex

    Joined:
    Sep 30, 2015
    Posts:
    126
    Looking at this closer and using the regular animator and not the network animator perhaps I am just misunderstanding how animation triggers work? Do they rely on exit times or something else?

    Triggering a StartWalking and StopWalking transition works fine in isolation. However, double clicking to move will trigger StartWalking once, then interrupt it and trigger StartWalking a 2nd time and only call StopWalking once the character has reached the 2nd destination. The character then continues to loop the walk animation even though StopWalking has been called.

    Switching this to booleans works as I would have anticipated and the character is returned to the idle state.
     
  3. TheLastVertex

    TheLastVertex

    Joined:
    Sep 30, 2015
    Posts:
    126
    And looks like I totally misunderstood triggers, so not a network animator issue from what I can tell. I didn't realize triggers were queued.

    Ignoring that I would still be curious if the network animator is worth using over a custom RPC solution instead, or setting up as much as possible to be handled on the client side.
     
  4. lbbbbbbbb

    lbbbbbbbb

    Joined:
    Feb 28, 2020
    Posts:
    1
    What are you using for your animations? I have tried mirror and mlapi and neither do the job(character stays t posing).
     
  5. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,735
    With Photon PUN using a player custom property works perfectly as a way to synchronise animations.