Multiplayer sprint

Hello. I’m trying to make sprint work in multiplayer, but I’ve noticed, that the MaxWalkSpeed variable in CharacterMovementComponent isn’t replicated.
So, what is the best correct-by-design method to replicate character speed?

  1. Use multicast/repnotify and set character speed into them.
  2. Replicate boolean variable and set character speed depending on it in tick function.
  3. Create custom movement component (like there: A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums).
  4. Increase/decrease character speed in both server and client without any replications.
    Thanks in advance

well…

You are almost on the right path… but…
Since character movement component doing client side prediction and server doing movement replay based on client data, you need to be carefull what you do or not do…

First of all i think hardcode character speed change is a terrible idea…
Character movement component has a virtual **GetMaxSpeed **function which made definitly for different character speeds.

So in theory close enough if you replicate a bool variable and override GetMaxSpeed and return different values based on your bool.
Assimung you know how to change replicated variable via RPC

Payoff for this method is responsive gameplay…
using a RPC to change variable and let the engine replicate down to the client seems a good idea and pretty easy to implement, but in practice if player have higher ping gameplay would be unresponsive because player input → time to rpc → time to replicate down → speed changed on client…

however you can change that bool on client before sending the rpc, but in this case you would broke the client prediction…

So far the best method is the third one: https://wiki.unrealengine.com/Author…acter_Movement because it would work well with client side prediction and you can replicate a simple bool as custom flag :wink:

Thanks for the helpful answer :slight_smile: