I've been working on an online multiplayer game using a client/server architecture and I have been following both Gabriel Gambetta's as Gaffer On Games's series about Client-Server Game Architecture, but I'm having a bit of trouble implementing/understanding the client side prediction and linear interpolation mainly because it's very theoretic.
I've been following the Snapshot Interpolation article and successfully implemented to the part where my game entities are synchronised between clients and servers but with the occasional hiccup/jittery effects. I'm sending snapshots (x, y, direction) every 10-15 frames on the client to the server which the server processes and send back to the clients.
If I understand correctly:
Client side prediction
Since there is a latency between the client and server, the client predicts and simulates what the next update from the server will be.
I have an object
o_input_manager which registers the inputs every frame and simulates what the effective new position of my
o_entity will be. These inputs are send to the server and directly applied to the
o_entity. When a new position update from the server, we interpolate from our old position to the new position.
Since we are sending position updates around 10 times per second, the entity will snap to every new position. We smoothly interpolate from our our old position to the new position from the server.
I'm mainly looking for pseudocode on how to implement these features both on the client as the server.