Multiplayer movement replication problem (video)

When i place a building block (with the server, or with the client) , the building block “jumping” on the client side. Here is a video aboute the bug: Unreal Engine 4 place object problem - YouTube

I don’t know for sure, as even though you made a very good video to explain it, it’s a little hard to spot what is happening, but I think the client side is jumping because the Server is replicating the block’s position on the server, to the Client as it was told to do. When the block simulates on the client side, the server keeps telling the client “No, that’s not where the block is, it’s over HERE.” and continually re-setting its position to whatever it is on the server as the client tries to move it around by simulating physics.

You should know that Unreal 4 uses PhysX engine for physics simulation which is nondeterministic, and so that even if things happened exactly the same way to add force to objects on both the server and client side (which it almost never does), then the physics would simulate a little differently on each machine, and even if they simulated the same, differences in framerate from one moment to the next can make things different.

It looks like you are simulating on client side and telling it not to simulate on Server side. You also set the Blocks to replicate and replicate movement. These settings mean that the server will replicate the block’s position to all the clients, whenever it changes on the server and the client is in relevance range.

The effect of this is that the server will keep re-setting the block position to its non-simulated position every time the client tries to move it with simulation.

There are several ways to solve this, but they are either difficult or make the movement client-authoritative instead of server-authoritative, which makes it very easy to cheat in multiplayer (but maybe your project is okay with that).
Some people have solved it both ways and you can find their solutions as plugins in the Unreal Marketplace (like the SmoothSync plugin - makes the movement client-authoritative), and I think Rama posted some things in the forums (answerhub is not the forums; that’s a different site), too. There are a few others.

Also, you can solve the problem yourself, best done via C++ programming.

Remember that CharacterMovement on the Character pawns has a lot of this stuff built in to it so that the Client communicates and calculates and smooths things out for you from client to server and back (so you use Add Movement Input node instead of SetLocation and similar), but EVERYTHING ELSE in Unreal does NOT do that, it only replicates from server to client, and without smoothing and prediction to compensate for lag.

Thank you for your advice. I buyed the Easy Smooth plugin, and it WORK! I have a little bit issues with this plugin, but much better than the replicate movement.

I’m glad it helped :slight_smile: Just be aware: SmoothSync uses client-authoritative movement so that means it is very easy for people to cheat or hack the game to move in whatever way they want including super speed, teleport, anything they want even if it’s not what your game allows by design.

I recommend you get on their Discord to get help resolving any remaining issues:

Thanks for the discord link. By the way my “biggest” problem with the plugin, is the “set actor collision enable”. If I doesn’t add the plugin, its work fine. In the client version the collision is on (if the server grab the object).

That sounds not like a movement problem related to a movement plugin, but rather a problem of you simply not setting the collision the same on all machines.

I don’t know if collision settings will replicate. If they do not, then you must:

  1. RPC to the server.
  2. In the server’s RPC handler, Set the Collision and then MultiCast (reliable) to all clients.
  3. In the Multicast handler for all clients, Set the Collision in the same way.

In this way the client that causes the collision settings to change will 1, ask the server to do something that will affect all machines, 2, the server does it on itself and tells all clients to do it, then 3, all the clients do it the same way.

I tried the multicast etc. but no effect. Here is another video: Collision problem - YouTube

OK, let’s start out more simple. What if you just have collision enabled always?

Everything work normally.

I fixed the issue. I made the multicast replication via the building block blueprint. Someone told me, the collision is local.