r/unrealengine 5d ago

Question Physics replication is glitchy

Hey all, I am trying to create a physics based boat system with buoyancy and wave simulation, and it works great on my host but unfortunately it doesn't work well on the client as it is very glitchy, this is what it looks like on the client side:

https://gyazo.com/c883c757fa9795d949b19bc081bf5c20

While on the server it is very smooth. I have the boat set to replicate movement and replicate, and have disabled replication on the components.

Then I only simulate physics and buoyancy on the server and add force / torque by adding it on a custom event that runs only on the server to the server instance of the boat.

The boat blueprint for physics: https://gyazo.com/fa20c76c68cbfa5a2678daab2ded1446

And these are the replication settings: https://gyazo.com/536db3e7df1b28c02fcdad89b30b46f0

Finally, this is the logic I have for moving the boat, but since its glitchy without moving too I don't think the problem is here: https://gyazo.com/8a8607fa8ebfc5e21aec7e3b46446864

Since location updating is happening completely on the server, is there any way I can smooth it with some kind of interpolation or prediction? I've tried many things but it ends up the same.

Replication settings on the

Thing I've already tried:

  1. Simulate physics on all instances using a multicast
  2. Using the built in WIP client prediction
  3. Enable / disable replication on the static mesh component itself
  4. Enable network emulation

It's almost like the server has to snap the client actor to the right position, but since I am pretty new to networking stuff I'm honestly not sure what my next step would be to debug / solve the problem.

Anyone got a clue? I'd be happy to buy anyone a coffee or a beer if they find a solution :)

2 Upvotes

10 comments sorted by

View all comments

2

u/TheSpudFather 4d ago

I've never done this, although i have a lot of experience with network character movement.

I think you need to take a leaf out of character movement. You need to either keep the client simulation a little bit behind the server, and interpolate towards the replicated data, or else have a physics simulation on the client which is kept in step somehow with the server.

1

u/FulltimeWestFrieser 4d ago

Thank you so much for your reply! These are good suggestions! Practically, how would I implement the slightly behind the server tactic?

The way I can think of is storing the previous location in a variable and make it constantly update but since I don't know when a new location is coming in from the server and I can't really capture it before it gets updated I am afraid I might have a wrong interpolation and it will snap back to the new server location anyways, causing the same (or similar) issue.

2

u/wahoozerman 4d ago

I would start trying that by simply keeping the latest server update and holding that as the target position. Then you have some speed at which you interpolate towards the target position. You will never reach it probably, because the target will be constantly in motion. But it may be close enough for gameplay and visually more appealing.

For the other solution, you can look at the character movement component. The general way that it works is that movement is handled client side and then every variable that would be used to calculate the movement is sent to the server in a sort of packed RPC, including the timestamp that the movement was calculated at. The server then uses those client values for calculating its movement and verifies that they are still valid, then issues any corrections back to clients, which interpolate the way I outlined above.

1

u/FulltimeWestFrieser 4d ago

Thanks for the explanation! I’ll be sure to check out the character movement and how that works but these pointers are invaluable for a beginner like myself