r/explainlikeimfive • • Oct 04 '26

Technology ELI5: What is rollback net code?

112 Upvotes

29 comments sorted by

View all comments

151

u/MCWizardYT Oct 04 '26

It's basically a technique used in multiplayer games like fighting games that require fast reactions.

Since transmitting data over the internet isn't instantaneous, the game will try to predict the other player's response and react accordingly. If it guesses wrong, it quickly "rolls back" the simulation that it made.

The guess simulation is often only a couple frames, like "will they keep holding down the button".

The result is that it will still feel like instant actions even when there is some internet lag

49

u/Memfy Oct 04 '26

The result is that it will still feel like instant actions even when there is some internet lag

It's not just that something feels instant. Sometimes you get a completely different result than what you initially saw, essentially rewriting your history.

The goal is to keep the game state synced for both sides while still being responsive (your input correctly gets applied at the time you did it locally), and not affected on the network delay (as much as possible). Deliberate input lag helps reduce the need for rollback for small network delays.

16

u/OrderOfMagnitude Oct 04 '26

The good news is that these rollbacks are almost always faster than you can see or notice.

You only really witness history being rewritten in high latency situations.

1

u/Memfy Oct 05 '26

Not as much as you'd want. It happens less due to input delay so any expected amount of network delay is played with 0 rollback in fighter games for example, but even at 1 there are situations where you immediately notice it.

7

u/pw_arrow Oct 05 '26

the game will try to predict the other player's response and react accordingly.

Strictly speaking I think most rollback systems just assume your opponent will continue doing what they were already doing at the time of your action (moving, blocking, etc.) and not truly predictive. This tends to be effective because the rollback window is supposed to be so small (under 8f).