Open Hasan-Jawaheri opened 4 years ago
Use this as a reference: https://gafferongames.com/post/state_synchronization/
General idea (some details can be found in above link):
RemoteControlledAI
performs all receiving functionality:
PlayerAI
inherits from RemoteControlledAI
PlayerAI
might need special handling for state reception because player is always ahead of where server thinks he is.PlayerAI
will send inputs to serverRemoteControlledAI
s on the server (player units) will not have their state controlled by players. But the simulation will accept input update types which it will apply on the RemoteControlledAI
of the sending player which will make the server simulate player's inputPlayerAI
on the player's side and RemoteControlledAI
on server and other players/clientsRemoteControlledAI
for all players/clients and will be any special AI on server sideRTBAI
and have input state but don't do any networking activity
Details about sending/receiving input, sending/receiving state, compressing/optimizing packets and error calculation/application can be found in the article https://gafferongames.com/post/state_synchronization/
Optimizations checklist:
PlayerAI
handling RemoteControlledAI
's state updates (because updates are received for past state, we should keep an error from past state and correct that rather than snapping)Motion is very jittery on client side because the framerate is highly varying. On server side, simulation runs at fixed 30 FPS and it is much smoother. This issue should allow running physics at a fixed step rate: https://github.com/Hasan-Jawaheri/Wasabi/issues/44 and needs to be implemented before this can be done
Functional requirements: