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
  1. User Manual

Examples

PreviousPickups, Drops, and Child ObjectsNextAdditive Levels

Last updated 1 year ago

Mirror includes several small examples to help you learn how to use various features and how to set things up so they work together. Only a select few have documentation pages, check the Mirror/Examples directory in your Unity Project for more examples of how to use Mirror.

  • The Additive Levels example demonstrates using Additive Scenes as levels with Scene Interest Management, custom scene loading with a fade transition, and teleporting the player from one scene to another via respawning.

  • The Additive Scenes example demonstrates a server additively loading a sub-scene into a main scene at startup, and having a server-only trigger that generates a message to any client whose player enters the trigger zone to also load the sub-scene, and subsequently unload it when they leave the trigger zone. Only players inside the trigger zone can see the objects in the sub-scene. Network Proximity Checker components are key to making this scenario work.

  • Basic is what it sounds like...the most rudimentary baseline of a networked game. Features SyncVars updating random UI data for each player.

  • Benchmark Allows for mass testing of Enemy NPC's (monsterous red cubes!). See the Spatial Hashing Interest Management component at work, joining clients will only receive data from nearby enemies.

  • Benchmark Idle Similar to above, mass test idle networked objects each with a colour sync var, settings can be changed via NetworkManager inspector.

  • Billiards Mouse drag the white ball to apply force, hits are send to server via [Command].

  • Billiards Predicted Similar to above, but with prediction, this solves the possible delay that a Command->ClientRpc/NetworkTransform position result, would normally have.

  • CCU SoonTM

  • Character Selection Demonstrates how to use multiple prefabs for player spawns in your game, along with name and colour customisation.

  • Chat A simple text chat example, send messages between players that login via Network Authenticator.

  • Common Contains miscellaneous features that are not full examples.

  • Couch Co-Op Add additional local players to your game, they all share same screen, different controls. Remote joining clients can do the same, allows for a combination of local players vs remote players, such as 2 vs 4, or 1 vs 4 vs 99 (granted you would have to setup 99 different controller/keyboard inputs for this).

  • Discovery Broadcasts on local network, clients can find servers without needing to input IP address or ports. Another popular use is, it can be adjusted to auto join first broadcasted game thats found (or create a game if none), a feature used often in VR or LAN game types.

  • Lag Compensation Rollback / Lag Compensation is a standalone, Unity / netcode independent algorithm. This is a simple demo to test it, without Mirror. We want this to be usable in all game engines.

    The demo intentionally introduces latency so that server / client cubes are at different positions when clicking.

  • The Multiple Concurrent Additive Scenes example demonstrates a server additively loading multiple instances of a sub-scene into a main scene at startup, with physics separation, and assigning players to the instances to play matches independently. is the key component that makes this example work.

  • Multiple Matches This example demonstrates how to run a large number of non-physics games concurrently in a single game server instance.

    This would be most appropriate for Card, Board, Puzzle, and Arcade games where there is no physics involved, just presentation and messaging.

    While this example is turn-based, real-time games work just as well.

  • A simple example for "How to build a multiplayer game with Mirror" is Pong. It illustrates the usage of NetworkManager, NetworkManagerHUD, NetworkBehaviour, NetworkIdentity, NetworkTransform, NetworkStartPositionand various Attributes.

  • Rigidbody Benchmark Mass test networked physics.

  • Rigidbody Physics Test differences between physics and network setups to find what is ideal for your scenario.

  • The Room System example demonstrates how to set up a "staging" scene where players assemble before starting a match. When all players are ready, the server sends them all a message to change scenes (along with the server itself) to the actual game play scene so they all come in at once. Includes fully playable game with a character controller where players collect server-spawned prizes for score.

  • Snapshot Interpolation Snapshot Interpolation is a standalone, Unity / netcode independent algorithm. This is a simple demo to test it, without Mirror. We want this to be usable in all game engines.

  • Sync Direction Sync List and Sync Var example, controlled via Client->Server sync direction.

  • This is a simple scene with animated tanks, networked rigidbody projectiles, and NavMesh movement.

  • Tanks Co-Op Take control of tank Vehicles, spawn as regular player prefab, interact with tank to enter, drive and shoot, exit to continue being regular player.

  • VR A selection of multiplayer-ready virtual reality examples that use Unitys XR toolkit, allows the use of multiple VR headsets with one setup.

Additive Levels
Additive Scenes
Basic
Multiple Additive Scenes
NetworkSceneChecker
Pong
Room System
Tanks