Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.Close
For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.Close
Networking is a very large, detailed topic. In Unity, it is extremely simple to create network functionality. However, it is still best to understand the breadth and depth involved with creating any kind of network game. This section explains the fundamentals of networking and the Unity-specific implementations of these concepts. If you are new to networking then it is highly recommended that you read this guide in detail before attempting to create a network game.
The High Level Overview is a good place to start or to refresh your knowledge of networking in general. From there, the Unity Networking Elements page takes the discussion to Unity’s implementation of the general concepts.
Unity makes extensive use of the Network View component to share data over networks and so it is very important to understand how this operates. One of the functions provided by Network Views is Remote Procedure Calls or RPC. This enables you to call a function on one or more remote machines which may be clients or servers.
Regarding the maintenance of information between networked computers, State Synchronization is a method of regularly updating a specific set of data across two or more game instances running on the network. Another subject is tracking which computer owns or controls which objects in the shared environment. Network Instantiation can be used to handle this task, although there are alternatives you can use when you need more control.
Discovering a computer is sometimes a matter of someone setting up a server machine and then inviting other players directly to participate. Where games offer anonymous or mass participation, a Master Server can be used as a place to advertise a game session and allow people to join. A master server can also use a technique called NAT punchthrough to ensure players can always connect, even when firewalls are in operation.
Reducing the amount of data transferred between computers will tend to improve performance; the page on minimizing bandwidth gives advice on how to achieve these optimizations.
On mobile devices, the Unity networking API is much the same as on desktop machines and so networked games will often work with little or no modification. The Mobile Networking page addresses some of the issues and performance considerations that do occur with mobile devices.