Best way to replicate timeline-changing anim variable?

What is the best way to replicate a variable that changes constantly by a timeline? (from client)
This variable is vital to animations, therefore updating it by network will result in a rubber lag disgusting effect.

  1. Of course i could just run that timeline on the server, but then the clients would get choppy lags.
  2. I could also call the timeline independently for each client by multicasting from the server, but then the owning client will get a ping delay between his keyboard action and the effect.
  3. Below is my current solution, which works okay, and does this by starting the timeline on the owning client before even asking the server to pass that to other clients.

I wonder if there is a less hacky solution, because the above way actually restarts the timeline on the owning client when multicast RPC is called. It is not that noticeable in this specific BP example but could mess stuff up in other cases.

Hello!

Well technically your solution works, but as you said can be terrible for networking…
I try to explain some techniques which may help you…

Network only inputs and simulate on clients:

Technically this technique as his name show super easy, but not really synced mechanism.
What you need do just network input and let client simulate “lean”.
If player start lean left right (or in whatever direction) you just replicate that input and start lean left / right (whatever) on other clients… Simply just play your timeline.
If player ends lean, send input to other clients to stop at desired lean…

Perhaps this may cause some “desync”, so when this simple system is done you can start iterate and implement further techniques like:

Server validation:
Once lean ends you can multicast actual lean value to validate clients lean value… if you have mismatch between values you can interpolate to that value, so every client will be mostly in sync.

Smoothing / Client predicting:
This technique also built on input (mostly used for movement) or movement values like velocity, torque etc.

In short this technique try to predict “movement” on client based on server validated values…
like client send wohoo im moving with 0,0,1 velocity - server check client can move and update his location - forwarding to other clients wohoo this actor was moved - other clients start movement - client send info again wohoo in this frame i moving with same value - server checks / forwards info - other clients continue simulating and check incomming locations of course…
then trouble comes… client lagging and not sending any info to the server in the next frame. server cant update other clients… what happens now?
other clients still simulate movement and predicting… when client can send info again server and other clients will check there was mismatch on the movement or predicting path was good… if not we correcting.

So technically clients just smoothing / predicting movement between two updates if he can and continue movement if no updates there but the last command was “move forward or we have velocity(0,0,1)”

Of course ton of other techniques exist, take a look and google about networked movement… im sure will help.

In your case i think simpliest if you add a replicated float to your character as “lean value” use some onrep functions and whenever your character is do lean, send server rpc to update server value…
server then will update lean value to other clients and with onrep you can lerp or interpolate between old and new values…

Yes some delay will be there, but honestly… we talking about multiplayer game… there will be always a delay… no network exist which can work without delay ;D even LAN sometimes have some small (1-2ms) delay…

So try to make friendship with the delay, because if not … that will be your worst nightmare in your multiplayer game :slight_smile:

thanks for your tips :]