0% found this document useful (0 votes)
402 views21 pages

Mirror Networking

Mirror Networking is a networking solution for Unity games. It uses a client-server model where the server, either dedicated or hosted, manages the game state and synchronizes it to connected clients. Data is synchronized from the server to clients but not vice versa, requiring the use of commands. SyncVars, SyncLists, etc. can synchronize player-specific data to just the owning client. Network discovery allows clients to find available servers on the local network. A tutorial example demonstrates a basic Pong game setup using a NetworkManager, NetworkIdentity, and NetworkTransform components.

Uploaded by

許峻嘉
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
402 views21 pages

Mirror Networking

Mirror Networking is a networking solution for Unity games. It uses a client-server model where the server, either dedicated or hosted, manages the game state and synchronizes it to connected clients. Data is synchronized from the server to clients but not vice versa, requiring the use of commands. SyncVars, SyncLists, etc. can synchronize player-specific data to just the owning client. Network discovery allows clients to find available servers on the local network. A tutorial example demonstrates a basic Pong game setup using a NetworkManager, NetworkIdentity, and NetworkTransform components.

Uploaded by

許峻嘉
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

Mirror Networking

Mirror Networking
• https://mirror-networking.com
• https://mirror-networking.com/docs/index.html
Mirror Networking for Unity
• Requires Unity 2018.4 LTS and Runtime .Net 4.x (default in Unity 201
9) and .Net 2.0 Compatibility is recommended
• In Mirror’s High Level API (HLAPI) system, multiplayer games include
• Server
• Dedicated server
• This is an instance of the game that only runs to act as a server.
• Host server
• The host server creates a single instance of the game (called the host), which acts as both serv
er and client.
• Client
Host server
State Synchronization
State Synchronization
• State synchronization refers to the synchronization of values such as i
ntegers, floating point numbers, strings and boolean values belonging
to scripts.
• State synchronization is done from the Server to remote clients.
• The local client does not have data serialized to it. It does not need it, because
it shares the Scene with the server.
State Synchronization
• Data is not synchronized in the opposite direction - from remote client
s to the server. To do this, you need to use Commands.
• SyncVars
• SyncLists
• SyncDictionary
• SyncHashSet
• SyncSortedSet
Sync To Owner
• It is often the case when you don't want some player data visible to ot
her players.
• In the inspector change the "Network Sync Mode" from "Observers"
(default) to "Owner" to let Mirror know to synchronize the data only
with the owning client.
Network Discovery
Network Discovery
• Suppose your are next to a friend. He starts a game in host mode and
you want to join him. How will your phone locate his?
• Finding out his IP address is not exactly intuitive or something kids ca
n do.
Network Discovery
• When your game starts, it sends a message in your current network a
sking "Is there any server available?".
• Any server within the same network will reply and provide informatio
n about how to connect to it.

• Network Discovery uses a UDP broadcast on the LAN enabling clients t


o find the running server and connect to it.
Tutorial
Ping Pong
Pong
• NetworkManager
• NetworkManagerHUD
• NetworkBehaviour
• NetworkIdentity
• NetworkTransform
• NetworkStartPosition
• NetworkingAttributes
NetworkManager object
• Setting
• Don't destroy on Load, Run in Background
• Network Info/Max connections will also be 2
• For playing Pong the maximum number of players is 2
• the properties for Offline Scene and Online Scene will stay empty
Creating the player
• PlayerObject a prefab has to be created
• containing at least a NetworkIdentity component
with Local Player Authority checked.
• The Local Player Authority allows the player to
control and modify the gameobjects propertie
s (e.g. for movement).
• The NetworkManager needs a reference to thi
s prefab, which is located in Spawn Info/Player
Prefab
• To have the player movement synchronized ov
er the network, the player prefab also contains
a NetworkTransform.
PlayerObject

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy