Multiplayer client movement is stuttering for the client

I try to make a multiplayer game and my client is very laggy. Movement is slow and camera/rotation is stuttering. I guess the reason is that I send my input to the server and the server then applies the movement to the client? But if it’s the case, how can I fix it?

The server is smooth (left) and the client is laggy (right)

this is for example my camera movement (character rotation)

I’d probably use the player controller add input to rotate the ship. It has network prediction build in (I’m guessing the two ships are player controlled).

I’d use floating pawn Movement for the ships too.

Didn’t know the floating pawn movement exists! Thanks for that. Movement works like a charm now.
Can you explain what you mean by “use the player controller add input to rotate the ship”?

Here is a quick tutorial on the floating movement and how to add the inputs.

OFC you can substitute the normal input events with the new enhanced ones.

I just changed everything as in this tutorial. Now my server works fine, but the client won’t move anymore. Here is my simple “up/down”:

When replicating is “Run on owning client”: The client can move, but the server won’t see.
When replicating is “Run on server”: The client can’t move at all.
When replicating is “Multicast”: The client can move, but the server won’t see.
The server can always move, and the client can see it moving.

Do not run it via an rpc but directly. It already has the built in logic.

image

still the same.
The server can always move, and the client can see it moving.
The client can move, but the server won’t see.

(server left, client right)

Do you have replicate movent ticked?

Yeah:

My static mesh is directly attached to the pawn. Is this a problem? Do i need an “DefaultSceneRoot” ?
image

I just created a new simple player pawn. Same as before: Server can move, client can see. Client can move, server can’t see.

Ok so it seems the replication works by default only if the base class is character…not ideal in the situation of using the floating movement component.

Can be slightly choppy at times due to not having any movement prediction but it works.
All replication on component is set to off

This looked really choppy, as you told.
Would it be bad to update the position every tick? At least locally it looks nice.

Yes, you would saturate your network capacity very quickly causing dropped commands and unpredictability.

Alright, ill take your way for now and will learn how to do my own movement prediction. Thank you very much!

game_II.zip (73.2 KB)

It’s not perfect but a lot better than the previous version. You’ll have to generate the c++ project though.

This looks way better! But the client is pretty much faster than the server and can fly through walls :smiley: Guess it will take some work to fix all this little things

You need to enable simulate physics on the root and set the gravity to 0 on the pawn. Then they don’t go through walls. Speed is also the same. => game_ii.zip project.

Seems that still random physics collisions can desync the client & server so another approach is needed. Perhaps replicating elements of the physics calculations.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.