Hello! I’m studying how to make multiplayer games and I came across something I don’t understand how to do correctly: The game loop on the server side.
I’m thinking about a space top down shooter now, just to limit the scope. In my case, it is a kryonet application with LIBGDX. What I have planned for the multiplayer follows:
Client sends spawn message TCP.
Server handles the message, spawning the client ship.
Server responds the message with a snapshot TCP.
–> if there are more than two players
Server sends a start game message TCP (for UI) and starts the game (spawning of aliens).
Client streams player input through UDP.
Server process the input simulating all players.
Server sends snapshots TCP/UDP? to players each server tick.
–> if game over condition is met
Server sends end game message TCP.
I have several questions though…
Q1 - How will the server run by it self? I though of making a separate thread that calls the methods for sending stuff to the client (the snapshots).
Q2 - How much time a server tick should have? Wouldn’t this depend on the clients game loop delay?
Q3 - I currently sync the spawning of bullets to the ship firing animation… is that going to be a problem since the rendering is client side?
Q4 - Valve’s article says in source that object positions are processed both locally and server side, with interpolation to always use the server over the client. Can that be
applied to shooting?
Q5 - Should the player send a input message each game loop tick? Or should I sample the input with time intervals?
Q6 - Should the server snapshots be sent over UDP or TCP?
Q7 - What calls the server update loop? Won’t the server simulation run without sync with the client?
Thanks so much for taking your time to read all this!
If there is any good article about this, or a example game, even books, send me the names! =)