Hi folks. So my online multiplayer game has simple 6DOF movement using the floating pawn movement class. When you move in any direction, the speed is 3500 - no acceleration, no physics force. You just go 3500 immediately. I set up my simple server movement replication like so and it works perfectly with a good connection:
But of course, on worse CPUs/network connections it can look jittery. For my case, what is the best way to “smooth” the jitter so that when the affected character’s movement replicates to other clients it doesn’t jitter or teleport but rather moves smoothly in the predicted vector? I imagine it’s one of the VInterp or Ease functions, but I am at a loss where to get a sort of “previous actor location” so that the two vectors I am easing from and to are legit. In other words, Interp and Ease require two vectors to smooth. I can get the current actor location, but what is the other vector I am trying to get? Is there another way to accomplish the fakery I’m trying to achieve?
For good measure, here are three ways that aren’t working really, but are doing something. The Ease function seems to smooth the best but I am basically using the same location from a few ticks before to simulate a “previous” actor location.
And if you’re wondering what the game plays like:
Here are the ideas that went through my mind:
- in the regular CharacterMovementComponent there are several variables that we can adjust regarding network replication, I suggest you check if such variables exist in PawnMovementComponent
- the “standard” way to do this according to google is to use movement prediction. for instance: you know the character’s current velocity so you can predict where he is likely going to be the next frame.
- Overwatch uses a strange system in addition to their prediction logic: they smoothly “snap” the client to its real location (I literally slide along few pixels with my character)
Here are my two cents.
Thanks Yun-Kun I will keep investigating those. But does anyone happen to have BP examples of network smoothing/rubberbanding working well?
Did you manage to find a way to fix your problem with this?
If you are not using CharacterMovement component, with Add to Movement Input nodes, etc., then you will have to create your own prediction and smoothing between the client and server, using standard procedures like how they explain it is done for other games going all the way back to the 1990s.
Or if CharacterMovement is not going to work for you, and you don’t want to go to the trouble of writing that network prediction and smoothing code, then you can take the other easy way and get the SmoothSync plugin off the Unreal Marketplace, which does similar things for non-Character pawn movement types. I got it while it was free but haven’t tried it out yet. Let me know if it’s awesome.