July
24
2015

Makinom supports the new Unity Multiplayer functionality introduced in Unity 5.1.

Makinom 1.1.0 added basic support for Unity Multiplayer funactionality, you can find the networking settings in Game > Networking Settings.

Networking Basics

Before using Unity’s multiplayer functionality, you should learn the basics in the Unity manual.

Server and Client

In a networking environment, you need a server and a client. You can start a server by using the Start Server node in a schematic. A client is started using the Start Client node – when starting a client and a server in the same application/game, you should start a local client.

To enable a client to spawn a player, you need to set the client to be ready, either using a Set Client Ready node or using the Ready option in the Start Client node.

Game Objects and Spawning

Game objects that are used in a networking environment (e.g. a player, a bullet or an enemy) and are synchronized across all connected clients must have a NetworkIdenity component attached at the root and must be spawned through the server.

Some schematic nodes have options to perform their task in the networking environment (i.e. perform on the server and update all clients), e.g. spawning a prefab in the network only needs enabling the Network Spawn option in the Spawn Prefab node. There are several Unity components available to synchronize game objects after they’ve been spawned in the networking environment, e.g. the NetworkTransform component.

Prefabs that are spawned in the network must first be registered. Player prefabs (added in Game > Game Settings) and pooling prefabs (Base/Control > Game Object Pools) are registered automatically. Additionally, you can add prefabs to be registered in the networking settings. Pooling is currently not used in networked games.

Scenes

A client can load the current scene of the server by using the Load Scene node and selecting the Server scene origin.

You can change the server’s scene (also from a client) and cause all connected clients to also load the scene by using the Load Server Scene node.

Data Synchronization

Networked applications/games need to synchronize some data. You can synchronize game states and variables (global and object).

Game States

A game state can be synchronized in the network when the Network Synchronize option is enabled in the game state’s settings.

Synchronization of game states can be done automatically when enabling it in the networking settings (by default enabled). A client’s game states can be updated when connecting to the server and synchronize changes. Changes work in both ways, i.e. when a game state on the client is changed, the server will be notified, updating all other clients.

You can also use the Synchronize Game States node to synchronize game states manually.

Variables

Global and object variables can be either included or excluded from synchronization. By default, all variables will be synchronized (exclude without any excluded variable keys).

Automatic synchronization for global variables is enabled in the networking settings. Object variables can enable this in the Object Variables component – this also synchronizes local object variables (without an object ID). A client’s variables can be updated when connecting to the server (or when the object variables component is initialized) and synchronize changes. Changes work in both ways, i.e. when a variable on the client is changed (or removed), the server will be notified, updating all other clients.

You can also use the Synchronize Variables node to synchronize variables manually.