Explanation and additional notes

Hello,

The explanation is this:
The cube is moved on the client (but not replicated). So the client sees that the cube is moving. The server doesn’t see any changes in the movement because the client doesn’t send any updates to the server about him moving the cube.

I however tried experimenting a little bit. I got curious about the fact that why doesn’t server correct the position of the cube on the client, even though we set movement replication to true.
I thought that it might be because the position is not updated on the server. And since it isn’t updated, no messages are sent to the client. This is done for optimization purposes. It however does create a problem. With this solution, the server does not ensure that everyone sees what they should see. This means, that for example, the player could cheat by moving some geometry in the map, and thus see behind that geometry. The server will not check the state of the wall, and thus the player can cheat.

So, I edited the code a little bit. The client is still updating its cube’s position, moving it slowly. However, the server at the same time sets the cube’s position to its starting position each frame. I expected that by calling SetActorLocation(startingPosition) on each frame, the server would update the client with new values each frame. And each frame, the client’s cube would try to move forward, but would be moved back to its starting position due to updates received from the server. This was not the case however. The cube still moved on the client without resetting its position. So I assumed that even when resetting the position each frame on the server, the updates will not be sent (only the first one is sent. I think…) because the position itself is not actually changing.

To test out if I was correct, I made the client move the cube 20cm per second, and server move the cube 5cm per second. This confirmed by suspicion. On server side, the cube was moving smoothly 5cm per second. But on the client window, the cube moved forward and then snapped back. And it did so each frame (each time an update was received from the server). The cube on client snapped back to the server’s updated position because the cube was moving faster on the client than on the server.

So in conclusion, updates from the server are sent ONLY when the properties change.

Is there a way to make sure that the client does not cheat by disabling or moving geometry? How to do it without sending info about each piece of geometry?

Thanks!

Privacy & Terms