Converting a single-player game to Unity Multiplayer
Scene Objects
Multiplayer Lobby
Converting a single-player game to Unity Multiplayer
This document describes steps to converting a single player game to a multiplayer game, using the new Unity Multiplayer networking system. The process described here is a simplified, higher level version of the actual process for a real game; it doesn’t always work exactly like this, but it provides a basic recipe for the process.
NetworkManager set-up
Add a new GameObject to the Scene and rename it “NetworkManager”.
Add the NetworkManager component to the “NetworkManager” GameObject.
Add the NetworkManagerHUD component to the GameObject. This provides the default UI for managing the network game state.
Add a NetworkTransform component to the player Prefab
Update input and control scripts to respect isLocalPlayer
Fix Camera to use spawned player and isLocalPlayer
For example, this script only processes input for the local player:
using UnityEngine;
using UnityEngine.Networking;
public class Controls : NetworkBehaviour
{
void Update()
{
if (!isLocalPlayer)
{
// exit from update if this is not the local player
return;
}
// handle player input for movement
}
}
Basic player game state
Make scripts that contain important data into NetworkBehaviours instead of MonoBehaviours