Looking to program a top-down PVP game (12 ~ 16 players max) that involves a lot of projectiles and hitboxes on a 2D space.
My idea starts with a netcode like this:
QUESTION ONE: Server runs first. Clients will join a little later, so server game frame is likely going to be accumulating before receiving any client inputs. So when a client enters the match, the server will tell the client which game frame it’s on (i.e 128), by the time that reaches the client, there will already be a mismatch since the server game frame is up a couple of numbers. I’m aware the client must always be ahead of the server, so will I have to add extra dummy frames by a certain amount, i.e ping or a fixed amount for everyone?
QUESTION TWO: The server and client both run at a 60hz rate. The c…
Looking to program a top-down PVP game (12 ~ 16 players max) that involves a lot of projectiles and hitboxes on a 2D space.
My idea starts with a netcode like this:
QUESTION ONE: Server runs first. Clients will join a little later, so server game frame is likely going to be accumulating before receiving any client inputs. So when a client enters the match, the server will tell the client which game frame it’s on (i.e 128), by the time that reaches the client, there will already be a mismatch since the server game frame is up a couple of numbers. I’m aware the client must always be ahead of the server, so will I have to add extra dummy frames by a certain amount, i.e ping or a fixed amount for everyone?
QUESTION TWO: The server and client both run at a 60hz rate. The client will attempt to send input data to the server every 16ms (let’s mark this as input request #56 as an example). The server will run in a continuous loop attempting to read all input request per frame matching its server frame(or tick?) number (the current server frame being 56). then simulate game world yadda yadda. Is this the right way to do this? I’m aware that the server will not be able to read a request by a client if they’re falling behind. I’m thinking that the server will just create duplicates of previous inputs to fill up the empty gaps to keep the client in check.
QUESTION THREE: reconciliation. exactly how do I approach this? I have a base code that can achieve this but there is still jittering happening with the approach above that I’m experiencing. The server will wait every 1/10 seconds to send finalized game states to all clients to reconcile while attempting to replay inputs from the client to adhere to server changes.
I’m still pretty new to this and it’s still a very complex subject and I’ve watched documentaries on this and articles, so maybe a bit of human feedback would help just a bit.