Network Reference Guide

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. The following page will explain the fundamentals of networking concepts, and the Unity-specific executions of these concepts for you to use. If you have never created a network game before, it is highly recommended that you read this guide in detail before attempting to create one.

High Level Overview

This section will outline all the concepts involved in networking. It will serve as an introduction to deeper topics.

Networking Elements in Unity

This section of the guide will cover Unity's execution of the ideas discussed above.

Network View

Network Views are Components you use to share data across the network. They are extremely important to understand. This page will explain them in detail.

RPC Details

RPC stands for Remote Procedure Call. It is a way of calling a function on a remote machine. This may be a client calling a function on the server, or the server calling a function on all or specific clients, etc. This page explains RPC concepts in detail.

State Synchronization

State Synchronization is a method of regularly updating a specific set of data across two or more game instances running on the network.

Network Instantiate

One difficult subject in networking is ownership of an object. Who controls what? Network Instantiation will determine this logic for you. This page will explain how to do this. It will also explain the complex alternatives, for situations when you just need more control.

Master Server

The Master Server is like a game lobby where servers can advertise their presence to clients. It is also a solution to enabling communication from behind a firewall or home network. When needed it makes it possible to use a technique called NAT punchthrough (with help from a facilitator) to make sure your players can always connect with each other. This page will explain how to use the Master Server.

Minimizing Bandwidth

Every choice you make about where and how to share data will affect the bandwidth your game uses. This page will share some details about bandwidth usage and how to keep it to a minimum.

iOS

Boot up with Networking for iOS.

Networking on Mobile devices.

iOS and Android

Networking for mobile devices (iOS / Android)

The Unity iOS/Android Networking engine is fully compatible with networking for desktop devices, so your existing networking code should work on iOS/Android devices. However, you may want to re-engineer your code if it is mainly to be used with Wi-Fi or cellular networks. Moreover, depending on the mobile, the networking chip may also be the bottleneck since pings between mobile devices (or between the mobile device and the desktop) are about 40-60 ms, even in high performance Wi-Fi networks.

Using Networking you can create a game that can be played simultaneously from desktop and iOS over Wi-Fi or cellular networks. In the latter case, your game server should have a public IP address (accessible through the internet).

Note: EDGE / 3G data connections go to sleep very quickly when no data is sent. Thus sometimes you may need to "wake-up" networking. Just make the WWW class connect to your site (and yield until it finishes) before making the Unity networking connection..

Android

Networking on Mobile devices.

iOS and Android

Networking for mobile devices (iOS / Android)

The Unity iOS/Android Networking engine is fully compatible with networking for desktop devices, so your existing networking code should work on iOS/Android devices. However, you may want to re-engineer your code if it is mainly to be used with Wi-Fi or cellular networks. Moreover, depending on the mobile, the networking chip may also be the bottleneck since pings between mobile devices (or between the mobile device and the desktop) are about 40-60 ms, even in high performance Wi-Fi networks.

Using Networking you can create a game that can be played simultaneously from desktop and iOS over Wi-Fi or cellular networks. In the latter case, your game server should have a public IP address (accessible through the internet).

Note: EDGE / 3G data connections go to sleep very quickly when no data is sent. Thus sometimes you may need to "wake-up" networking. Just make the WWW class connect to your site (and yield until it finishes) before making the Unity networking connection..

Page last updated: 2013-08-12