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

Russian Call Girls in Karol Bagh Aasnvi āž”ļø 8264348440 šŸ’‹šŸ“ž Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi āž”ļø 8264348440 šŸ’‹šŸ“ž Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi āž”ļø 8264348440 šŸ’‹šŸ“ž Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi āž”ļø 8264348440 šŸ’‹šŸ“ž Independent Escort S...soniya singh
Ā 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
Ā 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
Ā 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
Ā 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
Ā 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
Ā 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
Ā 
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
Ā 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
Ā 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
Ā 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
Ā 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
Ā 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
Ā 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Intelisync
Ā 
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
Ā 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
Ā 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
Ā 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
Ā 

Recently uploaded (20)

Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
Ā 
Russian Call Girls in Karol Bagh Aasnvi āž”ļø 8264348440 šŸ’‹šŸ“ž Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi āž”ļø 8264348440 šŸ’‹šŸ“ž Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi āž”ļø 8264348440 šŸ’‹šŸ“ž Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi āž”ļø 8264348440 šŸ’‹šŸ“ž Independent Escort S...
Ā 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
Ā 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
Ā 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Ā 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
Ā 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
Ā 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
Ā 
Call Girls In Mukherjee Nagar šŸ“± 9999965857 šŸ¤© Delhi šŸ«¦ HOT AND SEXY VVIP šŸŽ SE...
Call Girls In Mukherjee Nagar šŸ“±  9999965857  šŸ¤© Delhi šŸ«¦ HOT AND SEXY VVIP šŸŽ SE...Call Girls In Mukherjee Nagar šŸ“±  9999965857  šŸ¤© Delhi šŸ«¦ HOT AND SEXY VVIP šŸŽ SE...
Call Girls In Mukherjee Nagar šŸ“± 9999965857 šŸ¤© Delhi šŸ«¦ HOT AND SEXY VVIP šŸŽ SE...
Ā 
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
Ā 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
Ā 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
Ā 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
Ā 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
Ā 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
Ā 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
Ā 
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
Ā 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Ā 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Ā 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
Ā 

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