Actual networking

In a previous post I looked into client side prediction, how it works, and why we do it. Yet I realized, the environment I was working in didn't have a single one of those problems. I was running on the loopback interface, with zero latency and zero packet loss, and absolutely no way of seeing if the network-compensation code even worked. So I added a random "packet-loss" by simply not sending packets based on a random value — and my game promptly crashed.

{more …}

Client side prediction

In a client-server set up, the server is the absolute authority how objects move in the game world, including all the player characters. This introduces a problem when playing over the internet vis-a-vis network latency, or lag. With round-trip times often a fair bit into the three digit range in milliseconds, it means whenever you turn or move, there'll be one or two tenths of a second delay before anything happens on screen. Such a delay is clearly noticeable and not at all acceptable for real-time/action games.

To counteract this delay, we turn to client-side prediction. The server is still the authority on everything in the game world, we just try to guess what the server will do next, and how it'll interpret our input.

{more …}