Unity RTS Engine

  1. Home
  2. Unity RTS Engine
  3. Multiplayer (Mirror)
  4. Network Lobby Manager

Network Lobby Manager

The Network Lobby Manager component is the default lobby manager component that comes with Mirror.

For the RTS Engine, we’ll be using its child class from the integration package, it’s called NetworkLobbyManager_Mirror.


Only fields that are relevant to the RTS Engine will be discussed here, you can also refer to the Mirror’s documentation page regarding this component for more information about the rest of the fields.

  1. General:
    1. Dont Destroy On Load: Make sure it’s set to true.
    2. Run In Background: Make sure it’s set to true.
  2. Network Info: 
    1. Transport: Make sure this references the Telepathy Transport attached to the same object.
    2. Network Address: Input here the default network address to be used when hosting/joining a multiplayer game. The Network Lobby Manager UI also allows to have an input text field in order to allow the player to modify this field in the multiplayer menu.
  3. Spawn Info:
    1. Player Prefab: A prefab which includes the NetworkFactionManager_Mirror that is created when the game/map scene is loaded and that manages each local player’s faction when the game is running. An example prefab can be found in the project tab in the following path: RTS Engine Integration Packs -> Mirror -> Prefabs under the name “NetworkFactionManager_Mirror”. The prefab includes the Network Identity component with Local Player Authority enabled and the NetworkFactionManager_Mirror component which is inherited from the NetworkBehaviour component from Mirror.
      1. Lock Step Cycle: As the multiplayer is built using a lockstep model, the lockstep cycle length needs to be defined in this field. This represents the time at which the server will send collected inputs from all players in the form of commands to all clients to be performed at the same time for each player.
      2. Timeout Time: When a clients syncs out and falls behind in simulating the game in comparison to other clients, he’s given the time (in seconds) in this field in order to catch up and sync or he’ll get kicked for timing out when the timer is up.
      3. Sync Test: This allows the server/host to continuously inspect players and check if they are on the same lockstep turn or not to avoid any sync issues and make sure that all players are simulating the same game. As soon as a client syncs out, the game freezes to wait for out-of-sync clients to catch up. Settings for the sync test include the Trigger Turn field which defines the lockstep turn at which the host/server will start performing sync tests. In addition, the Reload Time field defines the time between each sync test (it’s recommended to have a value that is equal or very close to the Lock Step Cycle field above).
    2. Auto Create Player: Make sure it’s set to true.
  4. Lobby Settings:
    1. Show Lobby GUI: Make sure this is disabled.
    2. Min Players: Set to 1.
    3. Lobby Player Prefab: A prefab which includes the NetworkLobbyFaction_Mirror component that holds the player’s faction information in the lobby. It is spawned when the player connects to a lobby. An example of this object can be found in the project tab: RTS Engine Integration Packs -> Mirror -> Prefabs under the name of “NetworkLobbyFaction_Mirror”. The prefab includes the Network Identity component with Local Player Authority enabled and the NetworkLobbyFaction_Mirror component which is inherited from the Network Lobby Player component from Mirror. It also includes UI child objects which are used to represent the lobby player’s faction information.
      1. Show Lobby GUI: Make sure it’s disabled.
      2. Ready To Begin: Make sure it’s disabled.
      3. Index: This field will hold the faction ID of the player when the game starts. Leave at 0.
      4. Faction Color Image: A UI Button that is used to display the faction’s color. In the “On Click” event of the Button component, drag and drop the “NetworkLobbyFaction_Mirror” object as the event source and set the event to NetworkLobbyFaction_Mirror-> “OnFactionColorUpdated”.
      5. Faction Name Input: A UI Input field that is used to input and show the faction’s name. In the “On End Edit” event of the InputField component, drag and drop the “NetworkLobbyFaction_Mirror” object as the event source and set the event to NetworkLobbyFaction_Mirror-> “OnFactionNameUpdated”.
      6. Ready To Begin Button: A UI Button that is used to inform other players in the lobby that the local player is ready or not ready to start the game. The player joins the lobby as not ready. In the “On Click” event of the Button component, drag and drop the “NetworkLobbyFaction_Mirror” object as the event source and set the event to NetworkLobbyFaction_Mirror-> “ToggleReadyStatus”.
      7. Ready Image: A UI Image that is shown when the player is ready and hidden when he’s not.
      8. Faction Type Menu: A UI Dropdown which allows the player to pick a faction type to play with in the multiplayer game. In the “On Value Changed” event of the Dropdown component, drag and drop the “NetworkLobbyFaction_Mirror” object as the event source and set the event to NetworkLobbyFaction_Mirror-> “OnFactionTypeUpdated”.
      9. Kick Button: A UI Button that is only shown for the host and allows him to kick players from the lobby. In the “On Click” event of the Button component, drag and drop the “NetworkLobbyFaction_Mirror” object as the event source and set the event to NetworkLobbyFaction_Mirror-> “CallCmdKickPlayer”.
    4. Lobby Scene: Drag and drop the scene that has the multiplayer menu into this field.
    5. Gameplay Scene: Drag and drop one of the map scenes into this field, doesn’t matter which one at this point.
    6. All Players Ready: Must be disabled by default.
  5. RTS Engine:
    1. Game Version: Input the current version of the game here. Two players with different game versions can’t be in the same lobby/room.
    2. Allowed Colors: A list of the colors that a faction is allowed to have. Players can choose a color for their faction once in a lobby/room.
    3. Available Maps: A list that holds all the maps that can be used in a multiplayer game. For each map, a couple of settings must be defined:
      1. Scene: Drag and drop the game map’s scene into this field.
      2. Name: Name of the map to show in the UI menu.
      3. Description: When this map is selected, this description is displayed.
      4. Max Factions: Maximum amount of factions that this map supports.
      5. Initial Population: The initial amount of population for the factions in this map.
      6. Faction Types: A list of Faction Type Info asset files that define the possible faction types that can play in the map.
    4. Spawnable Prefabs: As the rest of the doc pages insist, all unit, building and resource prefabs must be placed in a path that ends with …/Resources/Prefabs. The spawnable prefabs list holds the prefabs that can be created in a multiplayer game. There’s no need to add them manually to the list as they can generated easily by clicking on the “Refresh Spawnable Prefabs” button from the inspector.

How can we help?