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

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
Prashant Warrier
Ā 
Game development with Cocos2d-x Engine
Game development with Cocos2d-x EngineGame development with Cocos2d-x Engine
Game development with Cocos2d-x Engine
Duy Tan Geek
Ā 
Game Project / Working with Unity
Game Project / Working with UnityGame Project / Working with Unity
Game Project / Working with Unity
Petri Lankoski
Ā 

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

Initial design (Game Architecture)
Initial design (Game Architecture)Initial design (Game Architecture)
Initial design (Game Architecture)
Rajkumar Pawar
Ā 
GamingAnywhere: An Open Cloud Gaming System
GamingAnywhere: An Open Cloud Gaming SystemGamingAnywhere: An Open Cloud Gaming System
GamingAnywhere: An Open Cloud Gaming System
Academia Sinica
Ā 
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
slantsixgames
Ā 

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

%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
Ā 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
Ā 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
Ā 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
Ā 

Recently uploaded (20)

%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
Ā 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Ā 
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...
Ā 
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
Ā 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
Ā 
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
Ā 
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
Ā 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Ā 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
Ā 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
Ā 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
Ā 
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 šŸ”āœ”ļøāœ”ļø
Ā 
%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
Ā 
Chinsurah Escorts ā˜Žļø8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ā˜Žļø8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ā˜Žļø8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ā˜Žļø8617697112 Starting From 5K to 15K High Profile Escorts ...
Ā 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
Ā 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
Ā 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
Ā 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
Ā 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
Ā 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
Ā 

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