A lightning talk on multiplayer networking that we gave at /dev/world/2015.
View Slide
FSCKING LAG
Video Games!
Multi-player videogames!
Server
ServerClient Client Client
ServerClient
ServerClient“I just killed player 1”
ServerClient“I just killed player 1”“ok”
ServerClient“I just killed player 1”“ok”BAD
ServerClient“I pressedthese buttons”“This is wherethings are”
ServerClient“I pressedthese buttons”“This is wherethings are”BETTER
PROBLEM
1 2Lag = 1 second Lag = 0.1 seconds
12Shoots!Runs!FROM PLAYER 1’S PERSPECTIVE:
ServerPlayer 1 Player 2
ServerPlayer 1 Player 2“I’m shooting!”(1 second ago)
ServerPlayer 1 Player 2“I’m shooting!”(1 second ago)“I’m running aroundthe corner!”(0.1 second ago)
ServerPlayer 1 has shot, andPlayer 2 is around the corner.Player 1’s shot missed.
ServerPlayer 1 Player 2“Player 2 is nowaround the corner.Player 1 shot, butmissed.”
Counter-Strike
ServerPlayer 1 shot, and at thetime, they were aiming atPlayer 2. Their should wouldhave hit.
ServerPlayer 1 Player 2“Player 1 shotPlayer 2.”
ServerPlayer 1 Player 2“Player 1 shotPlayer 2.”“Oh, and Player2 still ranaround thecorner. lol.”
ServerPlayer 1 Player 2“Player 1 shotPlayer 2.”“Oh, and Player2 still ranaround thecorner. lol.”wtf
Age of Empires
1500 Archers on a 28.8:Network Programmingin Age of Empires andBeyondMark Terrano, Paul Bettner
PROBLEM:1500 archersEach one has a positionEach one is moving
Each position isabout 4 bytes each
4 bytes ✕ 1500 =6000 bytes
6000 bytes ✕ 30frames/sec= 175 kB/s
SOLUTION:
DON’T SYNC STATE
SYNC PLAYER INTENT
ClientClientClient
ClientClientClient“I told myarchers to move.”
ClientClientClient“I told myarchers to move.”“I told a villager togather wood.”
ClientClientClientWait for everyone to finish this frame….
ClientClientClientArchers are moving, and thevillager is gathering wood.
NOT PERFECT
RUNS AT THESLOWEST PLAYER
DESYNCS
@thesecretlabrocketboxgame.tumblr.com