How to deal with network latency?

My character has an attack combo. If player continues to click the animation plays out but if he stops it plays the stop animation. Now the problem here is on network play there is a slight lag issue(this is on the same computer). The client animation continues longer then it should and doesn’t have a smooth transition. I understand if this is on a high ping network but this is local server. 0ms. On the server the animation always play smoothly, on client or otherwise.

What is the best way to work around this?

Ok so I was able to fix this doing a Run on Server that sequence off to a multicast and a run on own client. Not sure if this is good practice but for now the animation works smoothly.

Is this a normal thing to do in Networking blueprints?

I would do it a bit different (although i’m not quite sure if it would solve the problem, but just test it ! (: )

Make a replicated variable for each state of the combo. Use this to perform the animations.

Either you have an Animation Blueprint and you just use the variable to tell the AnimationBP to switch to another State.

Or you are playing the Animation directly in one of your Blueprints (i don’t know your exact setup! more information would be helpful!)

For the first method, you will want to have 2 parts of setting the variable. Since it is replicated, the server needs to change it in order for the other clients to get the updated variable (first part). If your client does that, only he will get the update (prevents from cheating). So you need to have a “Run On Server” event, that sets the variable. To counter the “lag” for the client that wants to do the combo, you will still want to set the variable locally on him (second part). So that he doesn’t need to wait for the Server to give him the updated variable. It’s like a visual fake for the client to not show lags.

For the second method, you will want to make the variable “OnRep Function”-replicated. Means you get a function assigned to the variable, that will get called on all clients once the variable was successfully updated.
In here, you can now call you functions to play the animations, based on the value of the updated variable (mostly you would use bools for this).

For the client calling the change and wanting to attack, you want to make a local function call too, to prevent him from waiting that the variable is updated. Otherwise he would feel the “lag” that the message has from him to the server and from the server back to him. Make sure to check if an Animation is already running, otherwise the OnRep call will most likely restart the animation you are already playing!

Yes I’m using the 2nd method, animation through blueprints. I have a really bad understanding on this whole network thing. Even after reading and watching every doc/tutorial ten times over.

Currently I’m using a multigate to order my attack and once the user stops attacking the multigate resets. Wouldn’t using the “OnRep Function” be the same since it is already “Run On Server”? Because I tried using a local function already but for some reason the server player doesn’t get the animation update. So the player is just sliding everywhere on the server side and that’s why I had to throw in the multicast with the local call.

This is my simplified version of my combo of now.

http://i.imgur.com/rvPGite.png

[picture link][1]

It works as intended right now but not sure if this uses extra bandwidth.