From what I've read, there's several components which go into rollback netcode and requirements.
1: Your game logic update (input/state update) has to be able to run independently of your rendering (draw stage/textures/etc) I think 7 times as fast?
2: The connections need to run over UDP p2p.
So my first question is, if my game draw is updating at once every 60 frames, does that mean my game logic, input, network read, has to update once every 8-9 fps?
And I imagine the loop looks something like this?
if(framecount%8==0){
pollnetwork();
updategamestate();
input = checkinput();
if(input){
sendinputacrossnetwork(input);
}
}
if(framecount%60==0){
render();
}
I imagine the order in which those are called is irrelevant.
So I have that in place, but where do I go from there?
Do host and peer first have to synchronise gameframes? Then every time a packet is sent between the two, they have to check what frame they're currently on, which frame they received then rewind and replay?
For example, if host is on frame 18 then won't the client frame when received be on frame 9? Because it's always updating, say 9 frames. And if the server receives client's frame 9, we go back 9 frames and redraw everything from 9 frames ago to the current state depending on what the user provided as inputs?
There's a lot I don't understand about rollback netcode and I've read a lot too but there's small implementation details that I can't figure out. I might even be missing the bigger picture.