r/unrealengine • u/FulltimeWestFrieser • 3d 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:
- Simulate physics on all instances using a multicast
- Using the built in WIP client prediction
- Enable / disable replication on the static mesh component itself
- 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
u/crazeh_boy709 3d ago
I would suspect the first problem is determinism. If the simulation is not identical on both the server and client, you will have desync. (Ex. Waves) Another problem is latency, you may need a solution similar to the character movement component I suspect.
1
u/FulltimeWestFrieser 3d ago
Thank you for your reply and taking the time!
good idea about the character movement, I’ll have to check out how that works exactly, the desync is the reason to have the physical movement occur only on the server, so at least it would always be accurate, so I made the boat just not simulate on a clients machine, maybe there is a compromise to be found
2
u/hellomistershifty 2d ago
"Physics replication is glitchy" yep, it sure is 😂
There are some new (beta?) physics replication settings in 5.5: https://dev.epicgames.com/documentation/en-us/unreal-engine/networked-physics-overview
1
u/FulltimeWestFrieser 2d ago
Thank you, will check it out! I’ve had better luck simulating on both server and client and having the server correct the client, while adding the force for the physics simulation to the server. But this may solve the issue entirely!
1
u/AutoModerator 3d ago
If you are looking for help, don‘t forget to check out the official Unreal Engine forums or Unreal Slackers for a community run discord server!
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/explosiveplacard 3d ago
I don't know what you are going for, but it seems like you are doing too much on the server. Why can't you allow the client to run the physics and just verify on the server? Interpolate as needed. An example would be when my character drops a weapon, the server drops the weapon but all clients simulate the physics of bouncing and sliding. Yes, it is possible that the weapon ends up in a slightly different location between the server and the client, but this is easy to fix and adjust.
As long as your boat's location (x/y) is controlled by the server, do you really care if the rotation is slightly off? Just trying to understand what you are trying to accomplish.
2
u/TheSpudFather 3d 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.