Prediction, Reconciliation, and Lag Compensation implemented on top of my custom networking stack in Unity.
General purpose high-level API demonstrated with a small FPS demo.
Read the blog posts or check out the source code on GitHub.
Lag compensation (and netcode overall) is a large topic with many different approaches. It took a lot of research to wrap my head around what we use to overcome lag in server-authoritative games and why we use these techniques. Once everything "clicked" together in my head, the code itself came naturally.
Some bugs were difficult to track down - a missing "+" in the tick accumulation in TickManager.cs would break server reconciliation. What really helped track down these bugs were useful debugging visualizations - suddenly I could see that old state was being applied. Creating various visualizations helped me track down all these tricky bugs.
I've finally wrapped my head around prediction, reconciliation, and lag compensation. Instead of building client-authoritative games, I can make responsive games that are much more resilient to cheating.
Every time I use my netcoe library (Tobo.Net), I find aspects that are annoying or hard to use and fix them. Making a different kind of project with my netcode let me iron out more bugs and identify some shortcomings (like excessive garbage allocation). The library will continue to improve with every project I make.
Especially for complex, interwoven systems, being able to see what is going on under-the-hood helps you identify the root causes of a problem.
It takes time, effort, and research. You need all the pieces in place to get actual results - without reconciliation your prediction won't feel good. You will run into frustrating bugs.
Understanding how each concept works and why it is needed is the important part to implement this netcode. The actual code comes naturally from the theory.
Creating netcode for a platform fighter is very different from an open world MMORPG, and you’ll need to tailor it to your project. However, the theory is similar and useful no matter what direction you go.
I might make it sound daunting, but once you understand the theory it is a fun challenge. There are plenty of resources out there to learn from.
I love programming because it lets me solve problems. If get satisfaction from solving puzzles or overcoming challenge, fixing a bug or seeing everything come together with your netcode will have you jumping in your chair.