Multiplayer and Networking
Setting up a multiplayer project
Multiplayer Overview
Related tutorials: Multiplayer Networking
There are two kinds of users for the Networking feature:
- Users making a Multiplayer game with Unity. These users should start with the NetworkManager or the High Level APIA system for building multiplayer capabilities for Unity games. It is built on top of the lower level transport real-time communication layer, and handles many of the common tasks that are required for multiplayer games. More info
See in Glossary.
- Users building network infrastructure or advanced multiplayer games. These users should start with the NetworkTransport API.
High level scripting API
Unity’s networking has a “high-level” scripting API (which we’ll refer to as the HLAPI). Using this means you get access to commands which cover most of the common requirements for multiuser games without needing to worry about the “lower level” implementation details. The HLAPI allows you to:
- Control the networked state of the game using a “Network ManagerA Networking component that manages the network state of a Project. More info
See in Glossary”.
- Operate “client hosted” games, where the host is also a player client.
- Serialize data using a general-purpose serializer.
- Send and receive network messages.
- Send networked commands from clients to servers.
- Make remote procedure calls (RPCs) from servers to clients.
- Send networked events from servers to clients.
Engine and Editor integration
Unity’s networking is integrated into the engine and the editor, allowing you to work with components and visual aids to build your multiplayer game. It provides:
- A NetworkIdentityA Networking component that allows you to assign an identity to your GameObject for the network to recognise it as a Local Player GameObject or a Server Only GameObject. More info
See in Glossary component for networked objects.
- A NetworkBehaviour for networked scriptsA piece of code that allows you to create your own Components, trigger game events, modify Component properties over time and respond to user input in any way you like. More info
See in Glossary.
- Configurable automatic synchronization of object transforms.
- Automatic synchronization of script variables.
- Support for placing networked objects in Unity scenesA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More info
See in Glossary.
- Network components
Internet Services
Unity offers Internet Services to support your game throughout production and release, which includes:
- Matchmaking service
- Create matches and advertise matches.
- List available matches and join matches.
- Relay server
- Game-play over internet with no dedicated server.
- Routing of messages for participants of matches.
NetworkTransport real-time transport layer
We include a Real-Time Transport Layer that offers:
- Optimized UDP based protocol.
- Multi-channel design to avoid head-of-line blocking issues
- Support for a variety of levels of Quality of Service (QoS) per channel.
- Flexible network topology that supports peer-to-peer or client-server architectures.
Sample Projects
You can also dig into our multiplayer sample projects to see how these features are used together. The following sample projects can be found within this Unity Forum post:
- Multiplayer 2D Tanks example game
- Multiplayer Invaders game with Matchmaking
- Multiplayer 2D space shooter with Matchmaking
- Minimal Multiplayer project
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Is something described here not working as you expect it to? It might be a Known Issue. Please check with the Issue Tracker at issuetracker.unity3d.com.
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thanks for helping to make the Unity documentation better!
Multiplayer and Networking
Setting up a multiplayer project