Hi, I'm trying to get a simple networking going as a proof of concept (eventually heading to 2 cubes "tanks" moving and firing shells at each other). This is more to learn concepts etc. at first. I've read lots of articles (gafferongames, the valve ones etc.) and I think I've got most of the ideas straight. i.e. the client gets the moves and sends them to the server. Client then predicts / extrapolates what happens (i.e. runs the full simulation locally) and then corrects when it gets data back from the server.
However when trying to write the code I've found I've still not got one thing down - which is how to join a client at the right frame.
I've looked around and the nearest I could see was https://www.gamedev.net/topic/683580-server-client-ticks-lag-compensation-game-state-etc/ and I just want to see if I've understood this correctly (my apologies for raking this up again - feel free to point me at any other existing articles/posts you're aware of)
In my mental model of this works:
- Server starts and is running a simulation. Let's say a frame every 30ms.
- At frame 1000 a client connects.
- Server adds a player object in frame 1000 and starts sending state packets back starting at frame 1000.
- Client receives frame 1000. It's also determined by this point that it's ping (round trip) is 100ms
- It now knows that frame 1000 happened ~50ms ago on the server, or just under 2 frames worth.
- When it sends a packet to the server, the server will get that in ~50ms and will be nearly at frame 1004
My question is what does the client do now. Does it take frame 1000 and extrapolate to frame 1004, display that and start sending any moves to the server so that the server gets movement data for 1004, and then client stays about 4 frames "ahead"?