Movement Replication Setup. Am I doing something silly here?

Hello everyone.

I’m entirely new to multiplayer and replication (and ue4 in general), but I’ve been fiddling about with replication and I’d like to ask if I’m doing something stupid because of something I don’t know about yet.

TLDR version:

I’m trying to setup simple sprint and crouch for multiplayer. Rather than using a RPC RunOnServer custom event with all the required functionality (sprinting for example), and then also implementing the same functionality on the pawn to avoid glitching due to the server and client mismatch, I have a movement state enum (walking, sprinting, crouching), which is set using RepNotify with all the functionality in the OnRep function. I’d like to know if this is a bad idea and if so why? Many thanks.

The Long version:

So, when I’ve been trying to figure this out, most of the implementation information I’ve found from online sources take similar approaches. i.e., Use a RunOnServer with lets say sprint using set_max_walk to a new value. Then in order to combat the glitching coming from the server and client sync also implementing that same functionality locally. While I get why this is, and why you need to do that it seems a little redundant so instead I tried the following:

  1. I use a RunOnServer custom event into a Set w/ Notify (RepNotify) enum:

  2. In the OnRep function the enum simply specifies which function should run depending on the movement state it is provided. As the enum is updated and sent to the clients they then run this.

  1. Just for completeness, here is the walking function:


Now this all seems to work perfectly fine. I have a simlar setup for crouching, which also seems to work perfectly fine. Everything replicates correctly. All Clients and server see all the movement correctly, and there is no glitchy movements because the clients are simply following which movement state the server is telling them they are in.

BUT. I haven’t seen anyone else online doing it like this, which makes me think, there’s probably a very good reason why, that I’m simply not aware of. One reason I can think of is that because the client is not implementing the behaviour directly (it has to wait for the server to tell it the enum has changed), there could be a lag over a real network.

So, in my attempt to not have to have to sets of identical movement code for server and client (thats really all I was trying to avoid here), am I doing something really stupid? And if so, could you tell me why so I can learn from it.

Thanks in advance.