Mirror
  • Mirror Networking
  • API Reference
  • Development Blog
    • A Brief History of Mirror
  • User Manual
    • General
      • Getting Started
      • Script Templates
      • Change Log
        • 2024 Change Log
        • 2023 Change Log
        • 2022 Change Log
        • 2021 Change Log
        • 2020 Change Log
        • 2019 Change Log
      • Deprecations
      • Migration Guide
      • Integrations
      • Timestamp Batching
      • TCP and UDP
      • CCU
      • SyncDirection
      • Round Trip Time (RTT)
      • Connection Quality
      • Lag Compensation
      • Client Side Prediction
      • History Bounds
      • Tests
      • NetGraph
    • FAQ
      • Execution Order
    • Transports
      • KCP Transport
      • Telepathy Transport
      • WebSockets Transport
        • Reverse Proxy
          • Windows
            • IIS
          • Linux
            • NGINX
            • Caddy
            • Apache
            • HA Proxy
        • SSL
      • Multiplex Transport
      • Latency Simulation Transport
      • Ignorance
      • LiteNetLib Transport
      • FizzySteamworks Transport
      • FizzyFacepunch Transport
      • Encryption Transport
      • Edgegap Transports
        • Edgegap Relay
        • Edgegap Lobby
    • Components
      • Network Animator
      • Network Authenticators
        • Basic Authenticator
        • Device Authenticator
      • Network Behaviour
      • Network Discovery
      • Network Identity
      • Network Manager
      • Network Manager HUD
      • Network Ping Display
      • Network Profiler
      • Network Rigidbody
      • Network Lerp Rigidbody
      • Network Room Manager
      • Network Room Player
      • Network Start Position
      • Network Statistics
      • Remote Statistics
      • Network Transform
        • Snapshot Interpolation
      • Deprecated
        • Network Proximity Checker
        • Network Scene Checker
        • Network Match Checker
        • Network Owner Checker
    • Interest Management
      • Spatial Hashing
      • Distance
      • Scene
      • Scene + Distance
      • Match
      • Team
      • Custom
      • Legacy
    • Guides
      • Authority
      • IDs
      • Attributes
      • Time Synchronization
      • Data types
      • Serialization
      • Synchronization
        • SyncVars
        • SyncVar Hooks
        • SyncEvent (Obsolete)
        • SyncLists
        • SyncDictionary
        • SyncHashSet
        • SyncSortedSet
      • Communications
        • Remote Actions
        • NetworkManager Callbacks
        • NetworkBehaviour Callbacks
        • Network Messages
      • GameObjects
        • Player Game Objects
        • Custom Character Spawning
        • Custom Spawn Functions
        • Scene GameObjects
        • Pickups, Drops, and Child Objects
    • Examples
      • Additive Levels
      • Additive Scenes
      • Basic
      • Billiards
      • Multiple Additive Scenes
      • Pong
      • Room
      • Tanks
      • EdgegapLobby
  • Server Hosting
    • The Pragmatic Hosting Guide
    • Cloud Hosting Guides
      • AWS
      • Google Cloud
      • Oracle Free Tier
    • Hosting with a Remote Desktop
    • Edgegap Hosting Plugin Guide
  • Security
    • Security Overview
    • Cheat Protection Stages
    • Cheats & Anticheats
  • Community Guides
    • Community Translations
    • Video Tutorials
    • Resources
    • Mirror Quick Start Project
    • Unity for MMORPGs
    • Unity Canvas HUD
    • Odin Inspector Support
    • Ready Up And Die!
    • iOS AppStore
    • Mirror Docker Guide
    • Gitbook Guide
    • Mirror Branding
    • Contributors Agreement
    • Documentation License
Powered by GitBook
On this page
  • Video Tutorials
  • Script Templates
  • Network Manager Setup
  • Player Prefab
  • Player Movement
  • Basic player game state
  • Remote Actions
  • Non-player GameObjects
  • Spawners
  • Spawn positions for players
  1. User Manual
  2. General

Getting Started

PreviousGeneralNextScript Templates

Last updated 2 years ago

This document describes steps to creating a multiplayer game with Mirror. 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.

Video Tutorials

Check out these showing you how to get started with mirror.

Script Templates

  • Create new Network Behaviours and other common scripts faster

See .

Network Manager Setup

  • Create a new Network Manager from the menu.

  • Add a new game object to the Scene and rename it “NetworkManager”.

  • Add the newly created Network Manager component to the “NetworkManager” game object.

  • Add the component to the game object. This provides the default UI for managing the network game state.

See .

Player Prefab

  • Find the Prefab for the player game object in the game, or create a Prefab from the player game object

  • Add the NetworkIdentity component to the player Prefab

  • Set the Player Prefab in the NetworkManager’s Spawn Info section to the player Prefab

  • Remove the player game object instance from the Scene if it exists in the Scene

Player Movement

  • Add a NetworkTransform component to the player Prefab

  • Check the Client Authority checkbox on the component.

  • Update input and control scripts to respect isLocalPlayer

  • Override OnStartLocalPlayer to take control of the Main Camera in the scene for the player.

For example, this script only processes input for the local player:

using UnityEngine;
using Mirror;

public class Controls : NetworkBehaviour
{
    void Update()
    {
        // exit from update if this is not the local player
        if (!isLocalPlayer) return;

        // handle player input for movement
    }
}

Basic player game state

  • Make scripts that contain important data into Network Behaviours instead of MonoBehaviours

  • Make important member variables into SyncVars

Remote Actions

  • Make scripts that perform important actions into Network Behaviours instead of MonoBehaviours

  • Update functions that perform important player actions to be commands

Non-player GameObjects

Fix non-player prefabs such as enemies:

  • Add the NetworkIdentity component

  • Add the NetworkTransform component

  • Register spawnable Prefabs with the NetworkManager

  • Update scripts with game state and actions

Spawners

  • Potentially change spawner scripts to be NetworkBehaviours

  • Modify spawners to only run on the server (use isServer property or the OnStartServer() function)

  • Call NetworkServer.Spawn() for created game objects

Spawn positions for players

  • Add a new game object and place it at player’s start location

  • Add the NetworkStartPosition component to the new game object

See for more information.

See .

See .

awesome videos
Script Templates
Assets > Create > Mirror
NetworkManagerHUD
Using the NetworkManager
Player Objects
State Synchronization
Remote Actions