Client-authoritative jitter ideas

I am investigating adding a small coop multiplayer mode to a shipped title where the player avatar is an aircraft with fairly complex physics driven movement. The game is not very competitive so I am not really concerned with cheating and I have built a proof of concept that works quite well using a ClientNetworkTransform and NetworkRigidBody on the root of the plane.

It works well except when the player planes are close to each other moving at reasonably high speed and then there is visible jitter. Has anyone dealt with this situation before or have any idea for solutions? I can imagine some kind of extrapolation based on the previous velocity of the vehicle but this is the first time I have used Unity networking so I am not sure where that should go, and having already set the Interpolation flag on the NetworkTransform would these solutions interfere with each other?

Thanks for any advice!

Well, dynamic rigidbody physics is painfully hard to do right over the network.

The issue is of course latency. Physics simulation runs on the server/host. The client’s colliders are thus affected by latency, yet at the same time I suppose the player input is not but rather applied directly?

If you send the player input to the server for processing, the jitter should be gone. But then you’d have a 100+ ms input delay which players will notice - but it may be okay for a slow moving flight sim if the plane is taking some time to adjust its heading anyway.

In all other cases it is very challenging to solve this situation. It would involve either running the physics simulation on each client with the server reconciling the collisions to best match each player’s input. This may require rolling back (going back in time) and re-simulating past frames up until now on the server and then send clients a modified position - which they’d have to lerp towards (with physics forces) while also continuing to simulate their local state of the physics simulation.

My head hurts even describing these steps and each part is non-trivial to implement. Probably not worth following through to be honest just in order to add a “small coop multiplayer” mode.

However, if you can make it work without physics, respectively only using kinematic bodies and simplified collisions that you solve yourself manually by lerping the player objects away from each other while accepting some amount of intersection to be unavoidable … then that may be a viable solution.

Thanks very much for your response, actually collision accuracy doesn’t seem to be too much of a problem so far, though I will need to make a solution to “fake” a force for the non-authoritative collider but I think that should be ok.

As I mentioned in the topic the client authoritative approach seems to work well for most cases so far so rather than doing a complete overhaul to support server authoritative + client prediction I’m really just looking for some ideas to try and smooth out the movement a bit, kind of like the boss room physics projectile sample.

For anyone who was interested in this I found that this asset https://assetstore.unity.com/packages/tools/network/smooth-sync-96925 from the store made a significant improvement to the problem. It is not perfect and at close range the other player vehicles movement is not entirely smooth but it is good enough for my purposes of building a proof of concept prototype.

I haven’t gone too deeply into how it works but it replaces ClientNetworkTransform and NetworkRigidbody with its own component which stores a buffer of transform data and interpolates or extrapolates using that.