SlideShare a Scribd company logo
1 of 46
Download to read offline
MOVING PIXELS ON
SOMEONE ELSE'S
SCREEN
INTRODUCTION TO UNITY NETWORKING
HELLO šŸ‘‹
Massimo Frasson
Giovanni Frigo
Computer Science student,
Game developer @ Belka
CTO & Co-founder of Belka
So, you want to develop
a multiplayer videogame?
LETā€™S DO THIS!
The main objective:
synchronizing things
The old-fashioned way
šŸ‘¶
The old-fashioned way
#
The old-fashioned way
šŸ‘“
The old-fashioned way
šŸ’€
Sounds like a lot of work!
TO THE RESCUE!
Network Stack in Unity
You were
here
>Your scripts here<
Setting up a multiplayer scene
Setting up a multiplayer scene
Setting up a multiplayer scene
Setting up a multiplayer scene
Setting up a multiplayer scene
SYNCING THE STATE
Server + Client 1
State sync: built-in objects
NetworkManager Other scene objects
(terrain, camera, light)
Player 1
ā€¦ā€Ø
ā€¢ NetworkIdentityā€Ø
ā€¢ NetworkTransform
Player 2
ā€¦ā€Ø
ā€¢ NetworkIdentityā€Ø
ā€¢ NetworkTransform
Client 2
Other scene objects
(terrain, camera, light)
Player 1
ā€¦ā€Ø
ā€¢ NetworkIdentityā€Ø
ā€¢ NetworkTransform
Player 2
ā€¦ā€Ø
ā€¢ NetworkIdentityā€Ø
ā€¢ NetworkTransform
Player n
ā€¦ā€Ø
ā€¢ NetworkIdentityā€Ø
ā€¢ NetworkTransform
Player n
ā€¦ā€Ø
ā€¢ NetworkIdentityā€Ø
ā€¢ NetworkTransform
Client n
Other scene objects
(terrain, camera, light)
Player 1
ā€¦ā€Ø
ā€¢ NetworkIdentityā€Ø
ā€¢ NetworkTransform
Player 2
ā€¦ā€Ø
ā€¢ NetworkIdentityā€Ø
ā€¢ NetworkTransform
Player n
ā€¦ā€Ø
ā€¢ NetworkIdentityā€Ø
ā€¢ NetworkTransform
Scene
Player 1
ā€¦ā€Ø
ā€¢ NetworkIdentityā€Ø
ā€¢ NetworkTransform
Player 2
ā€¦ā€Ø
ā€¢ NetworkIdentityā€Ø
ā€¢ NetworkTransform
Player n
ā€¦ā€Ø
ā€¢ NetworkIdentityā€Ø
ā€¢ NetworkTransform
State sync
The Network Identity component
controls a GameObjectā€™s unique
identity on the network, and it
uses that identity to make the
networking system aware of the
GameObject.
ā€¢ Unity-speciļ¬c objects (position, rotation,
animation..)
ā€¢ Simple variables (int, ļ¬‚oat, ..)
ā€¢ Everything serializable! (custom classes)
State sync
Sets the Unique ID of this
object on the network, so that
we know who has changes
State sync: built-in objects
Server + Client 1
State sync: built-in objects
NetworkManager Other scene objects
(terrain, camera, light)
Player 1
ā€¦ā€Ø
ā€¢ NetworkIdentityā€Ø
ā€¢ NetworkTransform
Player 2
ā€¦ā€Ø
ā€¢ NetworkIdentityā€Ø
ā€¢ NetworkTransform
Client 2
Other scene objects
(terrain, camera, light)
Player 1
ā€¦ā€Ø
ā€¢ NetworkIdentityā€Ø
ā€¢ NetworkTransform
Player 2
ā€¦ā€Ø
ā€¢ NetworkIdentityā€Ø
ā€¢ NetworkTransform
Player n
ā€¦ā€Ø
ā€¢ NetworkIdentityā€Ø
ā€¢ NetworkTransform
Player n
ā€¦ā€Ø
ā€¢ NetworkIdentityā€Ø
ā€¢ NetworkTransform
Client n
Other scene objects
(terrain, camera, light)
Player 1
ā€¦ā€Ø
ā€¢ NetworkIdentityā€Ø
ā€¢ NetworkTransform
Player 2
ā€¦ā€Ø
ā€¢ NetworkIdentityā€Ø
ā€¢ NetworkTransform
Player n
ā€¦ā€Ø
ā€¢ NetworkIdentityā€Ø
ā€¢ NetworkTransform
Scene
Player 1
ā€¦ā€Ø
ā€¢ NetworkIdentityā€Ø
ā€¢ NetworkTransform
Player 2
ā€¦ā€Ø
ā€¢ NetworkIdentityā€Ø
ā€¢ NetworkTransform
Player n
ā€¦ā€Ø
ā€¢ NetworkIdentityā€Ø
ā€¢ NetworkTransform
Server + Client 1
State sync: built-in objects
NetworkManager Other scene objects
(terrain, camera, light)
Player 1
ā€¦ā€Ø
ā€¢ NetworkIdentityā€Ø
ā€¢ NetworkTransform
Player 2
ā€¦ā€Ø
ā€¢ NetworkIdentityā€Ø
ā€¢ NetworkTransform
Client 2
Other scene objects
(terrain, camera, light)
Player 1
ā€¦ā€Ø
ā€¢ NetworkIdentityā€Ø
ā€¢ NetworkTransform
Player 2
ā€¦ā€Ø
ā€¢ NetworkIdentityā€Ø
ā€¢ NetworkTransform
Player n
ā€¦ā€Ø
ā€¢ NetworkIdentityā€Ø
ā€¢ NetworkTransform
Player n
ā€¦ā€Ø
ā€¢ NetworkIdentityā€Ø
ā€¢ NetworkTransform
Client n
Other scene objects
(terrain, camera, light)
Player 1
ā€¦ā€Ø
ā€¢ NetworkIdentityā€Ø
ā€¢ NetworkTransform
Player 2
ā€¦ā€Ø
ā€¢ NetworkIdentityā€Ø
ā€¢ NetworkTransform
Player n
ā€¦ā€Ø
ā€¢ NetworkIdentityā€Ø
ā€¢ NetworkTransform
NetworkTransformā€Ø
updates
Scene
State sync: built-in objects
This is cool!
How can I replicate it also for more
generic variables?
State sync: variables
Letā€™s set a random color to each player and keep it
synced!
State sync: variables
The [SyncVar] attribute tells the
server that once the variable is
changed on the server, it should also
inform everyone else about it
State sync: pretty much
anything serializable!
ā€¢ Basic types (integers, strings, ļ¬‚oats, ā€¦)
ā€¢ Unity types (Vector3, Color, ā€¦)
ā€¢ Serializable objects
ā€¢ Structs made up by types above
State sync: pretty much
anything serializable!
ā€¢ Basic types (integers, strings, ļ¬‚oats, ā€¦)
ā€¢ Unity types (Vector3, Color, ā€¦)
ā€¢ Serializable objects
ā€¢ Structs made up by types above
Bonus: Lists of the primitive types above!
COMMANDS & RPC
State sync: variables
Server + Client 1
NetworkManager Other scene objects
(terrain, camera, light)
Player 1
ā€¦ā€Ø
ā€¢ ColorControllerā€Ø
-[SyncVar] Color
Player 2
ā€¦ā€Ø
ā€¢ ColorControllerā€Ø
-[SyncVar] Color
Client 2
Other scene objects
(terrain, camera, light)
Player 1
ā€¦ā€Ø
ā€¢ ColorControllerā€Ø
-[SyncVar] Color
Player n
ā€¦ā€Ø
ā€¢ ColorControllerā€Ø
-[SyncVar] Color
Client n
Other scene objects
(terrain, camera, light)
Player 1
ā€¦ā€Ø
ā€¢ ColorControllerā€Ø
-[SyncVar] Color
Player 2
ā€¦ā€Ø
ā€¢ ColorControllerā€Ø
-[SyncVar] Color
Player n
ā€¦ā€Ø
ā€¢ ColorControllerā€Ø
-[SyncVar] Color
Color SyncVarā€Ø
updates
Scene
Player 2
ā€¦ā€Ø
ā€¢ ColorControllerā€Ø
-[SyncVar] Color
Player n
ā€¦ā€Ø
ā€¢ ColorControllerā€Ø
-[SyncVar] Color
Player 1
ā€¦ā€Ø
ā€¢ ColorControllerā€Ø
-[SyncVar] Color
State sync: variables
How can I set the color into the server?
šŸ¤”
State sync: variables
Server + Client 1
NetworkManager Other scene objects
(terrain, camera, light)
Client 2
Other scene objects
(terrain, camera, light)
Client n
Other scene objects
(terrain, camera, light)
Scene
CmdChangeColor
Player 2
ā€¦ā€Ø
ā€¢ ColorControllerā€Ø
-[SyncVar] Color
Player n
ā€¦ā€Ø
ā€¢ ColorControllerā€Ø
-[SyncVar] Color
Player 1
ā€¦ā€Ø
ā€¢ ColorControllerā€Ø
-[SyncVar] Color
Player 1
ā€¦ā€Ø
ā€¢ ColorControllerā€Ø
-[SyncVar] Color
Player 1
ā€¦ā€Ø
ā€¢ ColorControllerā€Ø
-[SyncVar] Color
Player 2
ā€¦ā€Ø
ā€¢ ColorControllerā€Ø
-[SyncVar] Color
Player n
ā€¦ā€Ø
ā€¢ ColorControllerā€Ø
-[SyncVar] Color
Player 2
ā€¦ā€Ø
ā€¢ ColorControllerā€Ø
-[SyncVar] Color
Player n
ā€¦ā€Ø
ā€¢ ColorControllerā€Ø
-[SyncVar] Color
Commands
The Client asks the server to perform an
action
The code is executed on the Server
Commands
This is executed on server!
RPC
The Server tells the client to execute some
code
The code is executed on each of the Clients
RPC
RPC
Client
RPC
Client
Server
RPC
Client
Server
Client
BUT
..it can get messy, if for each action
you always have the RPC and
Commands in the same ļ¬le!
GOING FURTHER
Messages
Used to send some info from a
speciļ¬c client to another
DEMO TIME!
Belka
Code: github.com/BelkaLab/unity-networking-demo
THANKS!
Questions?
@MaxFrax96
@john_frigo
@MaxFrax96
@john_frigo

More Related Content

What's hot

Unreal Engine Basics 03 - Gameplay
Unreal Engine Basics 03 - GameplayUnreal Engine Basics 03 - Gameplay
Unreal Engine Basics 03 - GameplayNick Pruehs
Ā 
Deterministic Simulation - What modern online games can learn from the Game B...
Deterministic Simulation - What modern online games can learn from the Game B...Deterministic Simulation - What modern online games can learn from the Game B...
Deterministic Simulation - What modern online games can learn from the Game B...David Salz
Ā 
Game engines and Their Influence in Game Design
Game engines and Their Influence in Game DesignGame engines and Their Influence in Game Design
Game engines and Their Influence in Game DesignPrashant Warrier
Ā 
Game development with Cocos2d-x Engine
Game development with Cocos2d-x EngineGame development with Cocos2d-x Engine
Game development with Cocos2d-x EngineDuy Tan Geek
Ā 
Data Ward Pitch, v1.0
Data Ward Pitch, v1.0Data Ward Pitch, v1.0
Data Ward Pitch, v1.0darkeningsoul
Ā 
2D Video Games with MacRuby
2D Video Games with MacRuby2D Video Games with MacRuby
2D Video Games with MacRubyMatt Aimonetti
Ā 
Games on Demand: Are We There Yet?
Games on Demand: Are We There Yet?Games on Demand: Are We There Yet?
Games on Demand: Are We There Yet?Academia Sinica
Ā 
Escape: Level Design Exercise in Unity
Escape: Level Design Exercise in UnityEscape: Level Design Exercise in Unity
Escape: Level Design Exercise in UnityPetri Lankoski
Ā 
Developing Multiplayer Games in Unity3D
Developing Multiplayer Games in Unity3DDeveloping Multiplayer Games in Unity3D
Developing Multiplayer Games in Unity3DAdrian Popovici
Ā 
Bringing Supernatural Thriller, "Oxenfree" to Nintendo Switch
Bringing Supernatural Thriller, "Oxenfree" to Nintendo SwitchBringing Supernatural Thriller, "Oxenfree" to Nintendo Switch
Bringing Supernatural Thriller, "Oxenfree" to Nintendo SwitchUnity Technologies
Ā 
Computer Games Inner Workings - I. Loukeris AIT
Computer Games Inner Workings - I. Loukeris AITComputer Games Inner Workings - I. Loukeris AIT
Computer Games Inner Workings - I. Loukeris AITAIT_Communications
Ā 
Cocos2d-x C++ Windows 8 &Windows Phone 8
Cocos2d-x C++ Windows 8 &Windows Phone 8Cocos2d-x C++ Windows 8 &Windows Phone 8
Cocos2d-x C++ Windows 8 &Windows Phone 8Troy Miles
Ā 
Game development -session on unity 3d
Game development -session on unity 3d Game development -session on unity 3d
Game development -session on unity 3d Muhammad Maaz Irfan
Ā 
Presentasi Seminar Unity (AMIKOM Game Dev)
Presentasi Seminar Unity (AMIKOM Game Dev)Presentasi Seminar Unity (AMIKOM Game Dev)
Presentasi Seminar Unity (AMIKOM Game Dev)Mas Bram
Ā 
Game Project / Working with Unity
Game Project / Working with UnityGame Project / Working with Unity
Game Project / Working with UnityPetri Lankoski
Ā 
Introduction to Unity3D Game Engine
Introduction to Unity3D Game EngineIntroduction to Unity3D Game Engine
Introduction to Unity3D Game EngineMohsen Mirhoseini
Ā 
What Is A Game Engine
What Is A Game EngineWhat Is A Game Engine
What Is A Game EngineSeth Sivak
Ā 
Casual and Social Games with Unity
Casual and Social Games with UnityCasual and Social Games with Unity
Casual and Social Games with UnityTadej Gregorcic
Ā 

What's hot (20)

Unreal Engine Basics 03 - Gameplay
Unreal Engine Basics 03 - GameplayUnreal Engine Basics 03 - Gameplay
Unreal Engine Basics 03 - Gameplay
Ā 
Deterministic Simulation - What modern online games can learn from the Game B...
Deterministic Simulation - What modern online games can learn from the Game B...Deterministic Simulation - What modern online games can learn from the Game B...
Deterministic Simulation - What modern online games can learn from the Game B...
Ā 
Game engines and Their Influence in Game Design
Game engines and Their Influence in Game DesignGame engines and Their Influence in Game Design
Game engines and Their Influence in Game Design
Ā 
Game development with Cocos2d-x Engine
Game development with Cocos2d-x EngineGame development with Cocos2d-x Engine
Game development with Cocos2d-x Engine
Ā 
Data Ward Pitch, v1.0
Data Ward Pitch, v1.0Data Ward Pitch, v1.0
Data Ward Pitch, v1.0
Ā 
2D Video Games with MacRuby
2D Video Games with MacRuby2D Video Games with MacRuby
2D Video Games with MacRuby
Ā 
Games on Demand: Are We There Yet?
Games on Demand: Are We There Yet?Games on Demand: Are We There Yet?
Games on Demand: Are We There Yet?
Ā 
Escape: Level Design Exercise in Unity
Escape: Level Design Exercise in UnityEscape: Level Design Exercise in Unity
Escape: Level Design Exercise in Unity
Ā 
Developing Multiplayer Games in Unity3D
Developing Multiplayer Games in Unity3DDeveloping Multiplayer Games in Unity3D
Developing Multiplayer Games in Unity3D
Ā 
Unity 3d Basics
Unity 3d BasicsUnity 3d Basics
Unity 3d Basics
Ā 
Flowcharts
FlowchartsFlowcharts
Flowcharts
Ā 
Bringing Supernatural Thriller, "Oxenfree" to Nintendo Switch
Bringing Supernatural Thriller, "Oxenfree" to Nintendo SwitchBringing Supernatural Thriller, "Oxenfree" to Nintendo Switch
Bringing Supernatural Thriller, "Oxenfree" to Nintendo Switch
Ā 
Computer Games Inner Workings - I. Loukeris AIT
Computer Games Inner Workings - I. Loukeris AITComputer Games Inner Workings - I. Loukeris AIT
Computer Games Inner Workings - I. Loukeris AIT
Ā 
Cocos2d-x C++ Windows 8 &Windows Phone 8
Cocos2d-x C++ Windows 8 &Windows Phone 8Cocos2d-x C++ Windows 8 &Windows Phone 8
Cocos2d-x C++ Windows 8 &Windows Phone 8
Ā 
Game development -session on unity 3d
Game development -session on unity 3d Game development -session on unity 3d
Game development -session on unity 3d
Ā 
Presentasi Seminar Unity (AMIKOM Game Dev)
Presentasi Seminar Unity (AMIKOM Game Dev)Presentasi Seminar Unity (AMIKOM Game Dev)
Presentasi Seminar Unity (AMIKOM Game Dev)
Ā 
Game Project / Working with Unity
Game Project / Working with UnityGame Project / Working with Unity
Game Project / Working with Unity
Ā 
Introduction to Unity3D Game Engine
Introduction to Unity3D Game EngineIntroduction to Unity3D Game Engine
Introduction to Unity3D Game Engine
Ā 
What Is A Game Engine
What Is A Game EngineWhat Is A Game Engine
What Is A Game Engine
Ā 
Casual and Social Games with Unity
Casual and Social Games with UnityCasual and Social Games with Unity
Casual and Social Games with Unity
Ā 

Similar to Moving pixels on someone else's screen: introduction to Unity networking

Photon Session / Unite12 Conference
Photon Session / Unite12 ConferencePhoton Session / Unite12 Conference
Photon Session / Unite12 ConferenceChristof Wegmann
Ā 
Initial design (Game Architecture)
Initial design (Game Architecture)Initial design (Game Architecture)
Initial design (Game Architecture)Rajkumar Pawar
Ā 
2004: Sƶldner - a Post Mortem
2004: Sƶldner - a Post Mortem2004: Sƶldner - a Post Mortem
2004: Sƶldner - a Post MortemTeut Weidemann
Ā 
GamingAnywhere: An Open Cloud Gaming System
GamingAnywhere: An Open Cloud Gaming SystemGamingAnywhere: An Open Cloud Gaming System
GamingAnywhere: An Open Cloud Gaming SystemAcademia Sinica
Ā 
Supersize Your Production Pipe
Supersize Your Production PipeSupersize Your Production Pipe
Supersize Your Production Pipeslantsixgames
Ā 
98 374 Lesson 02-slides
98 374 Lesson 02-slides98 374 Lesson 02-slides
98 374 Lesson 02-slidesTracie King
Ā 
East Coast DevCon 2014: Game Programming in UE4 - Game Framework & Sample Pro...
East Coast DevCon 2014: Game Programming in UE4 - Game Framework & Sample Pro...East Coast DevCon 2014: Game Programming in UE4 - Game Framework & Sample Pro...
East Coast DevCon 2014: Game Programming in UE4 - Game Framework & Sample Pro...Gerke Max Preussner
Ā 
Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)
Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)
Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)David Salz
Ā 
Supersize your production pipe enjmin 2013 v1.1 hd
Supersize your production pipe    enjmin 2013 v1.1 hdSupersize your production pipe    enjmin 2013 v1.1 hd
Supersize your production pipe enjmin 2013 v1.1 hdslantsixgames
Ā 
Sephy engine development document
Sephy engine development documentSephy engine development document
Sephy engine development documentJaejun Kim
Ā 
GDC 2015 ć§ć®ćƒć‚¤ć‚Øćƒ³ćƒ‰ć‚°ćƒ©ćƒ•ć‚£ćƒƒć‚Æć‚¹
GDC 2015 ć§ć®ćƒć‚¤ć‚Øćƒ³ćƒ‰ć‚°ćƒ©ćƒ•ć‚£ćƒƒć‚Æć‚¹GDC 2015 ć§ć®ćƒć‚¤ć‚Øćƒ³ćƒ‰ć‚°ćƒ©ćƒ•ć‚£ćƒƒć‚Æć‚¹
GDC 2015 ć§ć®ćƒć‚¤ć‚Øćƒ³ćƒ‰ć‚°ćƒ©ćƒ•ć‚£ćƒƒć‚Æć‚¹Takashi Imagire
Ā 
XNA for Windows Phone
XNA for Windows PhoneXNA for Windows Phone
XNA for Windows PhoneEd Donahue
Ā 
De Re PlayStation Vita
De Re PlayStation VitaDe Re PlayStation Vita
De Re PlayStation VitaSlide_N
Ā 
Computer Games Development Chapter 7
Computer Games Development Chapter 7Computer Games Development Chapter 7
Computer Games Development Chapter 7Umair Shafique
Ā 
Developing and optimizing a procedural game: The Elder Scrolls Blades- Unite ...
Developing and optimizing a procedural game: The Elder Scrolls Blades- Unite ...Developing and optimizing a procedural game: The Elder Scrolls Blades- Unite ...
Developing and optimizing a procedural game: The Elder Scrolls Blades- Unite ...Unity Technologies
Ā 
Scalability & Big Data challenges in real time multiplayer games
Scalability & Big Data challenges in real time multiplayer gamesScalability & Big Data challenges in real time multiplayer games
Scalability & Big Data challenges in real time multiplayer gamesYan Cui
Ā 

Similar to Moving pixels on someone else's screen: introduction to Unity networking (20)

Photon Session / Unite12 Conference
Photon Session / Unite12 ConferencePhoton Session / Unite12 Conference
Photon Session / Unite12 Conference
Ā 
Initial design (Game Architecture)
Initial design (Game Architecture)Initial design (Game Architecture)
Initial design (Game Architecture)
Ā 
Cocos2d game programming 2
Cocos2d game programming 2Cocos2d game programming 2
Cocos2d game programming 2
Ā 
Cocos2d programming
Cocos2d programmingCocos2d programming
Cocos2d programming
Ā 
2004: Sƶldner - a Post Mortem
2004: Sƶldner - a Post Mortem2004: Sƶldner - a Post Mortem
2004: Sƶldner - a Post Mortem
Ā 
GamingAnywhere: An Open Cloud Gaming System
GamingAnywhere: An Open Cloud Gaming SystemGamingAnywhere: An Open Cloud Gaming System
GamingAnywhere: An Open Cloud Gaming System
Ā 
Supersize Your Production Pipe
Supersize Your Production PipeSupersize Your Production Pipe
Supersize Your Production Pipe
Ā 
98 374 Lesson 02-slides
98 374 Lesson 02-slides98 374 Lesson 02-slides
98 374 Lesson 02-slides
Ā 
Unity workshop
Unity workshopUnity workshop
Unity workshop
Ā 
East Coast DevCon 2014: Game Programming in UE4 - Game Framework & Sample Pro...
East Coast DevCon 2014: Game Programming in UE4 - Game Framework & Sample Pro...East Coast DevCon 2014: Game Programming in UE4 - Game Framework & Sample Pro...
East Coast DevCon 2014: Game Programming in UE4 - Game Framework & Sample Pro...
Ā 
Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)
Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)
Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)
Ā 
Supersize your production pipe enjmin 2013 v1.1 hd
Supersize your production pipe    enjmin 2013 v1.1 hdSupersize your production pipe    enjmin 2013 v1.1 hd
Supersize your production pipe enjmin 2013 v1.1 hd
Ā 
Sephy engine development document
Sephy engine development documentSephy engine development document
Sephy engine development document
Ā 
GDC 2015 ć§ć®ćƒć‚¤ć‚Øćƒ³ćƒ‰ć‚°ćƒ©ćƒ•ć‚£ćƒƒć‚Æć‚¹
GDC 2015 ć§ć®ćƒć‚¤ć‚Øćƒ³ćƒ‰ć‚°ćƒ©ćƒ•ć‚£ćƒƒć‚Æć‚¹GDC 2015 ć§ć®ćƒć‚¤ć‚Øćƒ³ćƒ‰ć‚°ćƒ©ćƒ•ć‚£ćƒƒć‚Æć‚¹
GDC 2015 ć§ć®ćƒć‚¤ć‚Øćƒ³ćƒ‰ć‚°ćƒ©ćƒ•ć‚£ćƒƒć‚Æć‚¹
Ā 
XNA for Windows Phone
XNA for Windows PhoneXNA for Windows Phone
XNA for Windows Phone
Ā 
De Re PlayStation Vita
De Re PlayStation VitaDe Re PlayStation Vita
De Re PlayStation Vita
Ā 
Computer Games Development Chapter 7
Computer Games Development Chapter 7Computer Games Development Chapter 7
Computer Games Development Chapter 7
Ā 
Developing and optimizing a procedural game: The Elder Scrolls Blades- Unite ...
Developing and optimizing a procedural game: The Elder Scrolls Blades- Unite ...Developing and optimizing a procedural game: The Elder Scrolls Blades- Unite ...
Developing and optimizing a procedural game: The Elder Scrolls Blades- Unite ...
Ā 
Scalability & Big Data challenges in real time multiplayer games
Scalability & Big Data challenges in real time multiplayer gamesScalability & Big Data challenges in real time multiplayer games
Scalability & Big Data challenges in real time multiplayer games
Ā 
Unity
UnityUnity
Unity
Ā 

Recently uploaded

Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto GonzƔlez Trastoy
Ā 
Introducing Microsoftā€™s new Enterprise Work Management (EWM) Solution
Introducing Microsoftā€™s new Enterprise Work Management (EWM) SolutionIntroducing Microsoftā€™s new Enterprise Work Management (EWM) Solution
Introducing Microsoftā€™s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
Ā 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfryanfarris8
Ā 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
Ā 
call girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
call girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļøcall girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
call girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļøDelhi Call girls
Ā 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfWilly Marroquin (WillyDevNET)
Ā 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...kalichargn70th171
Ā 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
Ā 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
Ā 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
Ā 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
Ā 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
Ā 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
Ā 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
Ā 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedDelhi Call girls
Ā 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
Ā 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
Ā 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
Ā 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
Ā 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfkalichargn70th171
Ā 

Recently uploaded (20)

Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Ā 
Introducing Microsoftā€™s new Enterprise Work Management (EWM) Solution
Introducing Microsoftā€™s new Enterprise Work Management (EWM) SolutionIntroducing Microsoftā€™s new Enterprise Work Management (EWM) Solution
Introducing Microsoftā€™s new Enterprise Work Management (EWM) Solution
Ā 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Ā 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
Ā 
call girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
call girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļøcall girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
call girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
Ā 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
Ā 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
Ā 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Ā 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Ā 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
Ā 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
Ā 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
Ā 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
Ā 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
Ā 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Ā 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
Ā 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
Ā 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
Ā 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
Ā 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Ā 

Moving pixels on someone else's screen: introduction to Unity networking

  • 1. MOVING PIXELS ON SOMEONE ELSE'S SCREEN INTRODUCTION TO UNITY NETWORKING
  • 2. HELLO šŸ‘‹ Massimo Frasson Giovanni Frigo Computer Science student, Game developer @ Belka CTO & Co-founder of Belka
  • 3. So, you want to develop a multiplayer videogame?
  • 10. Sounds like a lot of work!
  • 12. Network Stack in Unity You were here >Your scripts here<
  • 13. Setting up a multiplayer scene
  • 14. Setting up a multiplayer scene
  • 15. Setting up a multiplayer scene
  • 16. Setting up a multiplayer scene
  • 17. Setting up a multiplayer scene
  • 19. Server + Client 1 State sync: built-in objects NetworkManager Other scene objects (terrain, camera, light) Player 1 ā€¦ā€Ø ā€¢ NetworkIdentityā€Ø ā€¢ NetworkTransform Player 2 ā€¦ā€Ø ā€¢ NetworkIdentityā€Ø ā€¢ NetworkTransform Client 2 Other scene objects (terrain, camera, light) Player 1 ā€¦ā€Ø ā€¢ NetworkIdentityā€Ø ā€¢ NetworkTransform Player 2 ā€¦ā€Ø ā€¢ NetworkIdentityā€Ø ā€¢ NetworkTransform Player n ā€¦ā€Ø ā€¢ NetworkIdentityā€Ø ā€¢ NetworkTransform Player n ā€¦ā€Ø ā€¢ NetworkIdentityā€Ø ā€¢ NetworkTransform Client n Other scene objects (terrain, camera, light) Player 1 ā€¦ā€Ø ā€¢ NetworkIdentityā€Ø ā€¢ NetworkTransform Player 2 ā€¦ā€Ø ā€¢ NetworkIdentityā€Ø ā€¢ NetworkTransform Player n ā€¦ā€Ø ā€¢ NetworkIdentityā€Ø ā€¢ NetworkTransform Scene Player 1 ā€¦ā€Ø ā€¢ NetworkIdentityā€Ø ā€¢ NetworkTransform Player 2 ā€¦ā€Ø ā€¢ NetworkIdentityā€Ø ā€¢ NetworkTransform Player n ā€¦ā€Ø ā€¢ NetworkIdentityā€Ø ā€¢ NetworkTransform
  • 20. State sync The Network Identity component controls a GameObjectā€™s unique identity on the network, and it uses that identity to make the networking system aware of the GameObject. ā€¢ Unity-speciļ¬c objects (position, rotation, animation..) ā€¢ Simple variables (int, ļ¬‚oat, ..) ā€¢ Everything serializable! (custom classes)
  • 21. State sync Sets the Unique ID of this object on the network, so that we know who has changes
  • 23. Server + Client 1 State sync: built-in objects NetworkManager Other scene objects (terrain, camera, light) Player 1 ā€¦ā€Ø ā€¢ NetworkIdentityā€Ø ā€¢ NetworkTransform Player 2 ā€¦ā€Ø ā€¢ NetworkIdentityā€Ø ā€¢ NetworkTransform Client 2 Other scene objects (terrain, camera, light) Player 1 ā€¦ā€Ø ā€¢ NetworkIdentityā€Ø ā€¢ NetworkTransform Player 2 ā€¦ā€Ø ā€¢ NetworkIdentityā€Ø ā€¢ NetworkTransform Player n ā€¦ā€Ø ā€¢ NetworkIdentityā€Ø ā€¢ NetworkTransform Player n ā€¦ā€Ø ā€¢ NetworkIdentityā€Ø ā€¢ NetworkTransform Client n Other scene objects (terrain, camera, light) Player 1 ā€¦ā€Ø ā€¢ NetworkIdentityā€Ø ā€¢ NetworkTransform Player 2 ā€¦ā€Ø ā€¢ NetworkIdentityā€Ø ā€¢ NetworkTransform Player n ā€¦ā€Ø ā€¢ NetworkIdentityā€Ø ā€¢ NetworkTransform Scene Player 1 ā€¦ā€Ø ā€¢ NetworkIdentityā€Ø ā€¢ NetworkTransform Player 2 ā€¦ā€Ø ā€¢ NetworkIdentityā€Ø ā€¢ NetworkTransform Player n ā€¦ā€Ø ā€¢ NetworkIdentityā€Ø ā€¢ NetworkTransform
  • 24. Server + Client 1 State sync: built-in objects NetworkManager Other scene objects (terrain, camera, light) Player 1 ā€¦ā€Ø ā€¢ NetworkIdentityā€Ø ā€¢ NetworkTransform Player 2 ā€¦ā€Ø ā€¢ NetworkIdentityā€Ø ā€¢ NetworkTransform Client 2 Other scene objects (terrain, camera, light) Player 1 ā€¦ā€Ø ā€¢ NetworkIdentityā€Ø ā€¢ NetworkTransform Player 2 ā€¦ā€Ø ā€¢ NetworkIdentityā€Ø ā€¢ NetworkTransform Player n ā€¦ā€Ø ā€¢ NetworkIdentityā€Ø ā€¢ NetworkTransform Player n ā€¦ā€Ø ā€¢ NetworkIdentityā€Ø ā€¢ NetworkTransform Client n Other scene objects (terrain, camera, light) Player 1 ā€¦ā€Ø ā€¢ NetworkIdentityā€Ø ā€¢ NetworkTransform Player 2 ā€¦ā€Ø ā€¢ NetworkIdentityā€Ø ā€¢ NetworkTransform Player n ā€¦ā€Ø ā€¢ NetworkIdentityā€Ø ā€¢ NetworkTransform NetworkTransformā€Ø updates Scene
  • 25. State sync: built-in objects This is cool! How can I replicate it also for more generic variables?
  • 26. State sync: variables Letā€™s set a random color to each player and keep it synced!
  • 27. State sync: variables The [SyncVar] attribute tells the server that once the variable is changed on the server, it should also inform everyone else about it
  • 28. State sync: pretty much anything serializable! ā€¢ Basic types (integers, strings, ļ¬‚oats, ā€¦) ā€¢ Unity types (Vector3, Color, ā€¦) ā€¢ Serializable objects ā€¢ Structs made up by types above
  • 29. State sync: pretty much anything serializable! ā€¢ Basic types (integers, strings, ļ¬‚oats, ā€¦) ā€¢ Unity types (Vector3, Color, ā€¦) ā€¢ Serializable objects ā€¢ Structs made up by types above Bonus: Lists of the primitive types above!
  • 31. State sync: variables Server + Client 1 NetworkManager Other scene objects (terrain, camera, light) Player 1 ā€¦ā€Ø ā€¢ ColorControllerā€Ø -[SyncVar] Color Player 2 ā€¦ā€Ø ā€¢ ColorControllerā€Ø -[SyncVar] Color Client 2 Other scene objects (terrain, camera, light) Player 1 ā€¦ā€Ø ā€¢ ColorControllerā€Ø -[SyncVar] Color Player n ā€¦ā€Ø ā€¢ ColorControllerā€Ø -[SyncVar] Color Client n Other scene objects (terrain, camera, light) Player 1 ā€¦ā€Ø ā€¢ ColorControllerā€Ø -[SyncVar] Color Player 2 ā€¦ā€Ø ā€¢ ColorControllerā€Ø -[SyncVar] Color Player n ā€¦ā€Ø ā€¢ ColorControllerā€Ø -[SyncVar] Color Color SyncVarā€Ø updates Scene Player 2 ā€¦ā€Ø ā€¢ ColorControllerā€Ø -[SyncVar] Color Player n ā€¦ā€Ø ā€¢ ColorControllerā€Ø -[SyncVar] Color Player 1 ā€¦ā€Ø ā€¢ ColorControllerā€Ø -[SyncVar] Color
  • 32. State sync: variables How can I set the color into the server? šŸ¤”
  • 33. State sync: variables Server + Client 1 NetworkManager Other scene objects (terrain, camera, light) Client 2 Other scene objects (terrain, camera, light) Client n Other scene objects (terrain, camera, light) Scene CmdChangeColor Player 2 ā€¦ā€Ø ā€¢ ColorControllerā€Ø -[SyncVar] Color Player n ā€¦ā€Ø ā€¢ ColorControllerā€Ø -[SyncVar] Color Player 1 ā€¦ā€Ø ā€¢ ColorControllerā€Ø -[SyncVar] Color Player 1 ā€¦ā€Ø ā€¢ ColorControllerā€Ø -[SyncVar] Color Player 1 ā€¦ā€Ø ā€¢ ColorControllerā€Ø -[SyncVar] Color Player 2 ā€¦ā€Ø ā€¢ ColorControllerā€Ø -[SyncVar] Color Player n ā€¦ā€Ø ā€¢ ColorControllerā€Ø -[SyncVar] Color Player 2 ā€¦ā€Ø ā€¢ ColorControllerā€Ø -[SyncVar] Color Player n ā€¦ā€Ø ā€¢ ColorControllerā€Ø -[SyncVar] Color
  • 34. Commands The Client asks the server to perform an action The code is executed on the Server
  • 36. RPC The Server tells the client to execute some code The code is executed on each of the Clients
  • 37. RPC
  • 41. BUT ..it can get messy, if for each action you always have the RPC and Commands in the same ļ¬le!
  • 43. Messages Used to send some info from a speciļ¬c client to another