SlideShare una empresa de Scribd logo
1 de 92
Descargar para leer sin conexión
@hunterloftis
Making Sense of Multiplayer
Hunter Loftis
Engineering Manager, Heroku
@ Connect.Tech 2018
1962
1987
1996
1998
2004
Pre-2011
"Netcode" experts
C++, TCP, UDP, ICMP, routing
@hunterloftis
2011 Renaissance
WebSocket protocol (+Node.js)
@hunterloftis
Shared Spaces
Shared Spaces
Shared Spaces
Shared Spaces
Shared Spaces
@hunterloftis
But...
@hunterloftis
Most people fail the first time.
@hunterloftis
Most people fail the first time.
I did!
@hunterloftis
Most people fail the first time.
I did!
... and the second, third, and fourth times too.
@hunterloftis
Common issues
@hunterloftis
Common issues
• Choppy updates
@hunterloftis
Common issues
• Choppy updates
• Laggy controls
@hunterloftis
Common issues
• Choppy updates
• Laggy controls
• Changes being applied and then un-applied
@hunterloftis
Common issues
• Choppy updates
• Laggy controls
• Changes being applied and then un-applied
• Inconsistent client behavior
@hunterloftis
Common issues
• Choppy updates
• Laggy controls
• Changes being applied and then un-applied
• Inconsistent client behavior
• Rule breaking
@hunterloftis
We're ignoring decades of
experience!
@hunterloftis
Netcode 101
@hunterloftis
What is real-time multiplayer?
@hunterloftis
What is real-time multiplayer?
A Lie.
"It turns out it’s all an illusion. A
massive sleight-of-hand."
- Glenn Fiedler,
Networking for Game Programmers
@hunterloftis
@hunterloftis
100% Scientific
bandwidth / $
compute / $
speed of light / $
Time
@hunterloftis
bandwidth / $
compute / $
speed of light / $
Time
@hunterloftis
Sharing an environment over
thousands of miles is impossible.
@hunterloftis
Instead, create an illusion:
@hunterloftis
Instead, create an illusion:
1. Input gives feedback immediately.
@hunterloftis
Instead, create an illusion:
1. Input gives feedback immediately.
2. Players believe they are sharing an environment.
@hunterloftis
Instead, create an illusion:
1. Input gives feedback immediately.
2. Players believe they are sharing an environment.
3. Everyone eventually ends up in the same state.
@hunterloftis
How? Entities + Stacked State
@hunterloftis
How? Entities + Stacked State
View
@hunterloftis
How? Entities + Stacked State
View
Predicted
@hunterloftis
How? Entities + Stacked State
View
Predicted
Interpolated
@hunterloftis
How? Entities + Stacked State
View
Predicted
Interpolated
Authoritative
@hunterloftis
How? Entities + Stacked State
View
Predicted
Interpolated
Authoritative
@hunterloftis
Entities
@hunterloftis
Entities
@hunterloftis
Entities
• Have a unique ID.
@hunterloftis
Entities
• Have a unique ID.
• Belong to an owner.
@hunterloftis
Entities
• Have a unique ID.
• Belong to an owner.
• Belong to a timeline.
Entities provide a way to partition state
{
id: 4,
x: 50,
y: 22,
angle: 0,
health: 0.7,
firing: false
}
@hunterloftis
Entities from different timelines can coexist.
time = 1.5s
time = 1.75s
@hunterloftis
Divergence sacrifices accuracy for smoothness.
@hunterloftis
Authoritative State
sendToServer({ hit: true })
@hunterloftis
Input In - State Out
Server
{ leftKey: true }
[{ id: 1, x: -10, y: 0 }
{ id: 2, x: 10, y: 0 }]
{ rightKey: true }
@hunterloftis
Authoritative Server
@hunterloftis
Authoritative Server
• Prevents cheating
@hunterloftis
Authoritative Server
• Prevents cheating
• Ensures eventual consistency
@hunterloftis
Authoritative Server
• Prevents cheating
• Ensures eventual consistency
• Allows secrets
@hunterloftis
"Update Rate"
How frequently the server sends updates to clients.
(eg, 10 Hz)
@hunterloftis
Interpolated State
@hunterloftis
Interpolation
@hunterloftis
Interpolation
• Stores the last two authoritative states in history.
@hunterloftis
Interpolation
• Stores the last two authoritative states in history.
• Animates from history[0] to history[1].
@hunterloftis
Interpolation
• Stores the last two authoritative states in history.
• Animates from history[0] to history[1].
• Extrapolates if new data doesn't arrive on time.
history[0] history[1] extrapolated
@hunterloftis
Predicted State
@hunterloftis
Client-Side Prediction
@hunterloftis
Client-Side Prediction
• Records a buffer of local input.
@hunterloftis
Client-Side Prediction
• Records a buffer of local input.
• Applies the buffer over the most recent
authoritative state.
@hunterloftis
Client-Side Prediction
• Records a buffer of local input.
• Applies the buffer over the most recent
authoritative state.
• Only simulates a subset of the rules.
@hunterloftis
Local input stacks on top of authoritative history to
push local entities further in time.
history[0] history[1]
input inputinput
@hunterloftis
View State
@hunterloftis
View State
@hunterloftis
View State
• Isn't propagated across the network.
@hunterloftis
View State
• Isn't propagated across the network.
• May be different per-client.
@hunterloftis
View State
• Isn't propagated across the network.
• May be different per-client.
• Adds details to authoritative state.
@hunterloftis
Putting it all together
@hunterloftis
A moment in time
Server
input 45input 46input 47
state (43)state (42)
state (41)
input 44
state (40)
@hunterloftis
Player B
Sees himself start moving up
immediately, then sees Player A
start moving up.
Player A
Sees herself start moving up
immediately, then sees Player B
start moving up.
Both players press UP at the same time.
@hunterloftis
Player B
Sees himself stop moving
immediately, then sees Player A
stop moving at the same height.
Player A
Sees herself stop moving
immediately, then sees Player B
stop moving at the same height.
Both players release UP at the same time.
@hunterloftis
The illusion has limits
Latency
Fighters/Sports
Twitchy shooters
Today's demo
Real-time strategy
Chess
@hunterloftis
Questions so far?
@hunterloftis
Questions so far?
View
@hunterloftis
Questions so far?
View
Predicted
@hunterloftis
Questions so far?
View
Predicted
Interpolated
@hunterloftis
Questions so far?
View
Predicted
Interpolated
Authoritative
@hunterloftis
Questions so far?
View
Predicted
Interpolated
Authoritative
@hunterloftis
ctdf.herokuapp.com
@hunterloftis
Questions?
https://github.com/hunterloftis/dogfight
http://www.pages.drexel.edu/~ecb44/print.html
https://www.pcgamer.com/netcode-explained/
http://www.gabrielgambetta.com/client-server-game-architecture.html
https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking
http://www.gamasutra.com/view/news/128323/Seven_Years_Of_World_Of_Warcraft.php
https://gafferongames.com/post/what_every_programmer_needs_to_know_about_game_networking
https://stackoverflow.com/questions/11436311/realtime-multiplayer-game-principles-for-tcp-and-node-js
"250 Handdrawn Textures" art by Daniel Cook
Plane sprites by Sujit Yadav
Particle sprites by Kenney

Más contenido relacionado

La actualidad más candente

Does a serial killer’s childhood affect their future
Does a serial killer’s childhood affect their futureDoes a serial killer’s childhood affect their future
Does a serial killer’s childhood affect their future
mrsalcido
 

La actualidad más candente (20)

自動運転車両開発におけるUE4の活用事例 | UNREAL FEST EXTREME 2020 WINTER
自動運転車両開発におけるUE4の活用事例 | UNREAL FEST EXTREME 2020 WINTER自動運転車両開発におけるUE4の活用事例 | UNREAL FEST EXTREME 2020 WINTER
自動運転車両開発におけるUE4の活用事例 | UNREAL FEST EXTREME 2020 WINTER
 
Serial murderers
Serial murderersSerial murderers
Serial murderers
 
Unity5とUE4の比較
Unity5とUE4の比較Unity5とUE4の比較
Unity5とUE4の比較
 
Unreal Engine.pptx
Unreal Engine.pptxUnreal Engine.pptx
Unreal Engine.pptx
 
Unreal Engine 4 Introduction
Unreal Engine 4 IntroductionUnreal Engine 4 Introduction
Unreal Engine 4 Introduction
 
Computer Forensic
Computer ForensicComputer Forensic
Computer Forensic
 
Keep Code Left - How to write better code in almost any language
Keep Code Left - How to write better code in almost any languageKeep Code Left - How to write better code in almost any language
Keep Code Left - How to write better code in almost any language
 
Data Privatisation, Data Anonymisation, Data Pseudonymisation and Differentia...
Data Privatisation, Data Anonymisation, Data Pseudonymisation and Differentia...Data Privatisation, Data Anonymisation, Data Pseudonymisation and Differentia...
Data Privatisation, Data Anonymisation, Data Pseudonymisation and Differentia...
 
Game Design 2: Lecture 5 - Game UI Wireframes and Paper Prototypes
Game Design 2: Lecture 5 - Game UI Wireframes and Paper PrototypesGame Design 2: Lecture 5 - Game UI Wireframes and Paper Prototypes
Game Design 2: Lecture 5 - Game UI Wireframes and Paper Prototypes
 
Web service implementation
Web service implementationWeb service implementation
Web service implementation
 
KGC 2016: HTTPS 로 모바일 게임 서버 구축한다는 것 - Korea Games Conference
KGC 2016: HTTPS 로 모바일 게임 서버 구축한다는 것 - Korea Games ConferenceKGC 2016: HTTPS 로 모바일 게임 서버 구축한다는 것 - Korea Games Conference
KGC 2016: HTTPS 로 모바일 게임 서버 구축한다는 것 - Korea Games Conference
 
Does a serial killer’s childhood affect their future
Does a serial killer’s childhood affect their futureDoes a serial killer’s childhood affect their future
Does a serial killer’s childhood affect their future
 
Editor Utility Widgetで色々便利にしてみた。
Editor Utility Widgetで色々便利にしてみた。Editor Utility Widgetで色々便利にしてみた。
Editor Utility Widgetで色々便利にしてみた。
 
Email investigation
Email investigationEmail investigation
Email investigation
 
Recast Detour.pptx
Recast Detour.pptxRecast Detour.pptx
Recast Detour.pptx
 
NDC14 범용 게임 서버 프레임워크 디자인 및 테크닉
NDC14 범용 게임 서버 프레임워크 디자인 및 테크닉NDC14 범용 게임 서버 프레임워크 디자인 및 테크닉
NDC14 범용 게임 서버 프레임워크 디자인 및 테크닉
 
UE4 MultiPlayer Online Deep Dive 基礎編2 -Traveling- (historia様ご講演) #ue4dd
UE4 MultiPlayer Online Deep Dive 基礎編2 -Traveling-  (historia様ご講演)  #ue4ddUE4 MultiPlayer Online Deep Dive 基礎編2 -Traveling-  (historia様ご講演)  #ue4dd
UE4 MultiPlayer Online Deep Dive 基礎編2 -Traveling- (historia様ご講演) #ue4dd
 
ECS (Part 1/3) - Introduction to Data-Oriented Design
ECS (Part 1/3) - Introduction to Data-Oriented DesignECS (Part 1/3) - Introduction to Data-Oriented Design
ECS (Part 1/3) - Introduction to Data-Oriented Design
 
Open Source Intelligence (OSINT)
Open Source Intelligence (OSINT)Open Source Intelligence (OSINT)
Open Source Intelligence (OSINT)
 
Social Media Forensics for Investigators
Social Media Forensics for InvestigatorsSocial Media Forensics for Investigators
Social Media Forensics for Investigators
 

Similar a Making Sense of Multiplayer

Test driven infrastructure development (2 - puppetconf 2013 edition)
Test driven infrastructure development (2 - puppetconf 2013 edition)Test driven infrastructure development (2 - puppetconf 2013 edition)
Test driven infrastructure development (2 - puppetconf 2013 edition)
Tomas Doran
 
An Introduction to Druid
An Introduction to DruidAn Introduction to Druid
An Introduction to Druid
DataWorks Summit
 

Similar a Making Sense of Multiplayer (20)

Scylla Summit 2017: Managing 10,000 Node Storage Clusters at Twitter
Scylla Summit 2017: Managing 10,000 Node Storage Clusters at TwitterScylla Summit 2017: Managing 10,000 Node Storage Clusters at Twitter
Scylla Summit 2017: Managing 10,000 Node Storage Clusters at Twitter
 
InfectNet Technical
InfectNet TechnicalInfectNet Technical
InfectNet Technical
 
Cloud-Native Observability
Cloud-Native ObservabilityCloud-Native Observability
Cloud-Native Observability
 
Managing 10,000 Node Storage Clusters at Twitter
Managing 10,000 Node Storage Clusters at TwitterManaging 10,000 Node Storage Clusters at Twitter
Managing 10,000 Node Storage Clusters at Twitter
 
[OPD 2019] Attacking JWT tokens
[OPD 2019] Attacking JWT tokens[OPD 2019] Attacking JWT tokens
[OPD 2019] Attacking JWT tokens
 
Test driven infrastructure development (2 - puppetconf 2013 edition)
Test driven infrastructure development (2 - puppetconf 2013 edition)Test driven infrastructure development (2 - puppetconf 2013 edition)
Test driven infrastructure development (2 - puppetconf 2013 edition)
 
Meetup on Apache Zookeeper
Meetup on Apache ZookeeperMeetup on Apache Zookeeper
Meetup on Apache Zookeeper
 
AdhearsionConf 2013 Keynote
AdhearsionConf 2013 KeynoteAdhearsionConf 2013 Keynote
AdhearsionConf 2013 Keynote
 
Thinking in Properties
Thinking in PropertiesThinking in Properties
Thinking in Properties
 
Killzone Shadow Fall: Threading the Entity Update on PS4
Killzone Shadow Fall: Threading the Entity Update on PS4Killzone Shadow Fall: Threading the Entity Update on PS4
Killzone Shadow Fall: Threading the Entity Update on PS4
 
Code reviews vs Pull requests
Code reviews vs Pull requestsCode reviews vs Pull requests
Code reviews vs Pull requests
 
An Introduction to Druid
An Introduction to DruidAn Introduction to Druid
An Introduction to Druid
 
Fire kit ios (r-baldwin)
Fire kit ios (r-baldwin)Fire kit ios (r-baldwin)
Fire kit ios (r-baldwin)
 
akka-scalaphx-jun2015
akka-scalaphx-jun2015akka-scalaphx-jun2015
akka-scalaphx-jun2015
 
Test Automation in the Microservices Oriented Enterprise by Shawn Wallace
Test Automation in the Microservices Oriented Enterprise by Shawn WallaceTest Automation in the Microservices Oriented Enterprise by Shawn Wallace
Test Automation in the Microservices Oriented Enterprise by Shawn Wallace
 
Inside the IT Territory game server / Mark Lokshin (IT Territory)
Inside the IT Territory game server / Mark Lokshin (IT Territory)Inside the IT Territory game server / Mark Lokshin (IT Territory)
Inside the IT Territory game server / Mark Lokshin (IT Territory)
 
DMCA#21: reactive-programming
DMCA#21: reactive-programmingDMCA#21: reactive-programming
DMCA#21: reactive-programming
 
Modern API Security with JSON Web Tokens
Modern API Security with JSON Web TokensModern API Security with JSON Web Tokens
Modern API Security with JSON Web Tokens
 
Best Practices for Design Hardware APIs
Best Practices for Design Hardware APIsBest Practices for Design Hardware APIs
Best Practices for Design Hardware APIs
 
BeJUG JAX-RS Event
BeJUG JAX-RS EventBeJUG JAX-RS Event
BeJUG JAX-RS Event
 

Más de Hunter Loftis

Más de Hunter Loftis (10)

Painting with Light: 3D Rendering in Golang
Painting with Light: 3D Rendering in GolangPainting with Light: 3D Rendering in Golang
Painting with Light: 3D Rendering in Golang
 
Painting with Light (Scenic City Summit)
Painting with Light (Scenic City Summit)Painting with Light (Scenic City Summit)
Painting with Light (Scenic City Summit)
 
Stop js-1999
Stop js-1999Stop js-1999
Stop js-1999
 
Production-Ready Node.js
Production-Ready Node.jsProduction-Ready Node.js
Production-Ready Node.js
 
Playing with Photons in JavaScript
Playing with Photons in JavaScriptPlaying with Photons in JavaScript
Playing with Photons in JavaScript
 
Nobody Wants Junior Engineers
Nobody Wants Junior EngineersNobody Wants Junior Engineers
Nobody Wants Junior Engineers
 
Stop JavaScripting like it's 1999
Stop JavaScripting like it's 1999Stop JavaScripting like it's 1999
Stop JavaScripting like it's 1999
 
We Will All Be Game Developers
We Will All Be Game DevelopersWe Will All Be Game Developers
We Will All Be Game Developers
 
ConvergeSE: We Will All Be Game Developers
ConvergeSE: We Will All Be Game DevelopersConvergeSE: We Will All Be Game Developers
ConvergeSE: We Will All Be Game Developers
 
ForwardJS: We Will All Be Game Developers
ForwardJS: We Will All Be Game DevelopersForwardJS: We Will All Be Game Developers
ForwardJS: We Will All Be Game Developers
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 

Making Sense of Multiplayer