#NetworkAnimator server-authoritative animations playing on client but not server

1 messages · Page 1 of 1 (latest)

dawn flicker
#

Hi, I am using the NetworkAnimator component to synchronise enemy actions in my game including attacks. The enemy behaviour is implemented via animator transitions, so for example an enemy may follow up an attack if parameters are met such as the distance from the player being below a threshold and if the attack can currently follow up.

The parameters are definitely only set on the server, I've checked every instance of SetBool/SetFloat and it is guarded by a check for if the code is runniing on the server. However, occasionally attacks play on the client while not playing on the server. I'm not sure if this is due to network lag as there may be a slight delay in updating the parameters or something I haven't configured in the NetworkAnimator settings

Are there any changes I can make to the settings or alternatives to the NetworkAnimator to mitigate this? Thanks

#

You can see in the above clip that on the client (left) the animator root motion is also not applied, so the attack is purely visual

tight epoch
#

If the bool is being set back to false in the same network tick it might not be sent to the clients

dawn flicker
#

The bool iis set by comparing an animator curve to 0.5f, so that I can edit follow up windows in the animation editor

#

So when theres a follow up attack the curve immediately goes to 0f which could be it

#

Not sure what other simple way there is to visually define the follow up windows, though
thought curves would work out

tight epoch
#

I usually use animation events

dawn flicker
#

I mean there's still always a chance of it being set to false in the same tick right? even with events

#

Like the event setting followUp to true could occur and then the actual follow up transition would set it to false potentially in the same tick

#

I'm not sure how I could have the client "wait" for atleast 1 tick before processing the transition to avoid this scenario

tight epoch
#

Your animations would have to be shorter than the tick rate for that to be a problem. As long as the animation event is near the end of the animation

dawn flicker
#

Am I thinking about this right?
Hope I'm explaining my theory correctly

dawn flicker
tight epoch
#

Oh I see. If you are doing like a combo system, then you will need more parameters. I'm using scriptable objects rather than strictly through the animator

dawn flicker
#

Yeah, I have it like a combo system

#

here's an example

tight epoch
#

Has exit time just means the animation will be forced to complete before it can transition

dawn flicker
#

So the main 3 parameters that cause transitions

  1. Distance
  2. Rand (between 0 and 1 for combo variation)
  3. followUp, so that transitions only occur when a follow up coul dhappen
dawn flicker
#

and the end of the animation has them returning to a neutral stance

#

I need some way to tell the animator to only follow up between frames x and y, but then after the transition I need to immediately reset that parameter
but then that causes the tick problem

tight epoch
#

If you want to d animation canceling then you'll need a parameter for each attack

dawn flicker
#

What happens if I use has exit time liike this, with the transition part way through an attack?

dawn flicker
tight epoch
#

I'll need to dig up my combo system

dawn flicker
#

So currently I have the transitions as

      attack1
      | followUp = true
      | Distance < 2
      V
      attack2
      | followUp = true
      | Distance < 2
______V__________________
| Rand < 0.5            | Rand > 0.5
| followUp = true       | followUp = true
attack3_1             attack3_2
#

So not sure what other params I'd need

dawn flicker
tight epoch
#

I was using SOs to set up the combo routes. When light attack was pressed the combo system would evaluate the combo state and then play the appropriate next attack

dawn flicker
#

So was the attack played using triggers?

#

or direictly usiing animator.CrossFade

tight epoch
#

No. It's playing states directly. I don't remember if I was using Crossfade or if that was adding too much delay

#

The animator was just a dump of animations with no connections. With different animations per character

dawn flicker
#

Oh right right

#

I did have the approach originally but I chose this because it'd be easier to graphically edit flowcharts

#

But you mention you did it with SOs so I'm curious how that looked when designing a tree?

dawn flicker
# dawn flicker

Like this one, where there are a lot of potential transitions with certain requirements

dawn flicker
tight epoch
#

Mine are pretty linear. Each attack could a following attack from a list of other attacks. Following up with a heavy attack will always give you that heavy attack

tight epoch
dawn flicker
#

So there's chances of anims playing only on the client like I sent

dawn flicker
tight epoch
dawn flicker
#

What if I make a second animator with no motion states

#

And each state has a State Machine Behaviour with the animation to play for that state

#

Then in OnEnter I can broadcast that animation to all clients?

#

That way unless an RPC is dropped clients will definetly play the animations of the server

#

And there's no chance of clients playing an animation that isn't playing on the server

#
  • I can maintain the graphical animator editor to design combos for enemies and have custom transition parameters
tight epoch
#

That should work. I haven't messed with State Machine Behaviors in a long time. The behavior tree package replaced that for me

dawn flicker
#

So essentially, don't sync the parameters: only the states with a State Machine Behaviour

dawn flicker
#

Alright, I'll try moving my attack system over to this and let you know how it goes
Tysm for the help 🙏

dawn flicker
#

@tight epoch Hm, the problem with trying to have the animator transitions handled on the server and broadcast changes to the client via RPCs is that transitions happen immediately on the client when they shouldn't

So I simply have to disable all transitions on the client, which I could do by adding a bool condition to every transition that is false on clients

I can't find another way to simply disable transitions, and can't find anything online so just asking if you knew a way you used or if it really is just impossible without adding those boolean requirements

#

Everything else works perfectly though, so thanks for the recommendation
i just have to choose which blend tree parameters have to be synced but apart from that it's perfect

tight epoch
#

It might be overkill but you can look into the Playables API. Technically, its building a custom animator.

dawn flicker
#

Thanks

#

Lemme see how it works