Download

Achieving replication for a rather strange scenario (it has a lot to do with physics)

Hi there!

I am having a tough time getting replication to work in the way I want it to (I bet you’ve seen hundreds of posts that begin like this). Basically, the playable characters in my game are pawns that do not use any kind of built-in controller. This was necessary to allow for the character to flip upside down and whatnot without inverting movement and character controls. As a result, I’ve built movement from the ground up using the AddLocalOffset function when on the ground and then use physical forces to simulate movement in the air. The system worked magically, right up until I tried to turn it into a multiplayer game. Most of my functions work out fine, but getting movement to replicate without the built-in controller to help has been a bit of a headache. I have since been updating the character’s position to the server, which then replicates this to other clients.

The ground movement using AddLocalOffset works perfectly (although I still need to interpolate/lerp to achieve smoother movement), but the physics-based movement stuff does not. This is due to the calling character now being locked into the last position sent to the server. It basically cancels out any physics forces as it constantly snaps the character to its current location. What this results in is physics movement that just barely moves the character in a jittery way (maybe a few cms every minute), but does not possess any follow-through/accumulative force. I was hoping to have the physics simulating on the client side with only the location being updated to the server/subsequent clients. This has everything to do with how I have been updating the client’s position. Upon sending the location to the server, it enforces that position on the calling client. It also makes the camera rotations a little laggy. I have tried to “ignore” the command to set its location/rotation when the replicated command is running on the owning client, but that doesn’t seem to work.

I have made basic multiplayer games before, but that was with all of the wonderful built-in stuff. Once you start doing your own thing, it becomes a bit tricky. Who knew?!

TL,DR (but recommend reading the fantastic backstory for more context): is there any way to give the client some sort of authority to simply update its location and rotation to the server without having to wait for the server’s go-ahead/ignoring its attempt to constrain it to whatever it sends? It’s a physics-based movement system, so I don’t want to replicate physics over the server (the stuff of nightmares), just the current location/rotation of the client as the forces act on it. This will also smooth out the issues related to lag when moving/rotating (freeing the client from constantly waiting for the server). Basically, if I could just set the transform of the client on the server and subsequent clients without forcing that location on the client itself, that would fix all of my issues. I want to couple this with a kind of shooter-preferred method that allows other clients to interact with how things are on their screens at the time, similar to how Overwatch does it (this will naturally take more time to get right, but I’m looking for any pointers to get started, which all starts with independent movement).

I’ve been all over the Internet trying to find an answer. A few wrote that the original Unreal Tournaments/most multiplayer games do something like this where the client sort of runs independently from the server and updates as much as it can (to make the client feel as smooth as possible without their latency making it feel like they’re trying to move a dead horse). Any help at all will be greatly appreciated!

Thanks!