Authoritative Netcode

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.

< Back to project list

Gameplay 4 players running around and shooting at each other
Effects Clip showcasing ragdolls, muzzle flash, blood effects
Reconcilation Gif showing debug gizmos of reconciliation in action
Rollback Video showing hitboxes rolling back to account for RTT
Debugging Video of input bug, with player rubber banding

Tools

  • Unity Engine
  • Blender & Substance Painter
  • Excel (task tracking)
  • Github

Roles

Programming
  • Research and implement lag-compensating techniques on top of my netcode stack
  • Make API easy to use for future projects
Research & Documentation
  • Compile lag-compensating techniques from online articles and GDC talks
  • Explain system architecture on blogs to other people can learn from it
Everything else
  • It is a personal project
  • Models, textures, audio, etc. by me*
  • *shotgun geometry created by my roommate

Challenges

Mental Models

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.

Obscure Bugs

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.


Skills Gained

Server-Authoritative Netcode

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.

Use of Tobo.Net

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.

Takeaways

Visualizations are extremely helpful for debugging

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.

Netcode is Complex

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.

Netcode is Theory Heavy

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.

Netcode is Bespoke

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.

... But you can make server-authoritative netcode too

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.

Overcoming challenge is satisfying

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.

Example of helpful visualizations


Gallery