I’m making a multiplayer boat racing game using purely physics for movement, mostly add force and add torque.
I’m currently trying to decide if to use Server Authorative Physics or Client Authorative Physics, what would be best? After doing some research I seem to be getting 50:50 each way.
Looking for quite a fast solution.
Main problems are arising from the buoyancy component that comes with the 4.26 water system.
Current Client Authority approach:
Owning client runs physics and tells server it’s lox,Rot,velocity.
In order for frame rate to not be a factor, I’ve set looping 0.04s timers on all the add force/add torque and set the tick intervals to be 0.04s on the static mesh component and the buoyancy component. The idea of this was to ensure the same amount of force is applied the same amount of times every second. Current problem is that the speeds are slightly different still and different frame rates.
Server Auth Approach:
Sim physics on both and turn on replicate movement.
Issue is the buoyancy component causes constant jittering.
If you don’t care about the possibility that players cheat, AND you don’t have boats where multiple players ride the same boat, then client authoritative will be easier.
If you want robust behavior even when multiple players ride the same boat, or if cheating is a concern, then you want server authoritative.
Note that you’ll need to write your own movement component and input replication for that to work well – send the control inputs to the server, and then react on them when you receive the replicated message back. But that’s OK for boats, which generally do not have instant turn reaction.
Like, Jwatte said, a server-authoritative system is going to require more work on your end in terms of movement prediction and replication. But, doing that kind of architecture is better for a competitive type of racing game.
Another thing you might consider is that heavy physics like the one you’re talking about might require a GPU on the server side, which is much more expensive on the cloud.
It really all comes down to whether you want to use Kinematic movement, or Physics movement.
Kinematic means you can simulate each boat in it’s own timestep and adopt a similar system to how the character movement system works. The advantage of this is you have full control over the sim and can do true Client Prediction / Server Auth - but you have to handle collision resolution yourself which can be difficult.
Physics means you simulate the objects as part of the physics scene, which gives decent collision responses and allows for better interaction with other objects. However, all physics objects must be simulated in lockstep with each other, so you cannot replay authoritive corrections without resimulating the whole scene. The only valid option for this IMO is client authority, with some server-side anti cheat, unless you can afford to replay the whole scene (most can’t).
Epic have been working on improving these approaches with their experimental Network Prediction plugin, but it’s incomplete and not production ready, and also requires running the engine in fixed timestep mode I believe. I also believe it’s primary developer just left Epic, so it’s future is uncertain.
If it’s any consolation, last we knew, Fortnite vehicles use client authoritative physics with server-side anti-cheat checks.
Both approaches have problems when players collide with each other, so don’t worry about that so much - that’s a fundamental problem with prediction models that can’t be solved unless you use a lockstep system.