Home

Awesome

Megacity Multiplayer

Contents and Quick Links

Megacity Multiplayer Overview

Megacity Multiplayer is an action-packed, shooter game based on the original Megacity sample. It leverages the power of Netcode for Entities for an immersive, multiplayer experience that can support 64+ players simultaneously. The latest DOTS packages and Unity Gaming Services (UGS) enhances the Megacity Multiplayer user experience. Megacity Multiplayer showcases how to create engaging and immersive multiplayer experiences with a suite of netcode and multiplayer tools, tech, and services.

Some important points of this demo are:

Important Note: This repository is deprecated and will no longer be maintained. For the latest features of ECS packages and the most recent version of this sample, please refer to the following repository: Megacity Metro. However, if you are specifically interested in Large-scale streaming or utilizing HDRP, please clone this repository.

Megacity Multiplayer Prerequisites

Megacity Multiplayer is compatible with Unity 2022 LTS and is currently tested on Windows and Mac. You can download the editor using the following link:

Recommended Specs for Mac

Recommended Specs for Windows 10

Important Note Before You Begin

The Megacity Multiplayer sample is large, so the first time cloning and playing the sample may take more time than expected. Subsequent plays should load much quicker because of caching.

First time clone and load time estimates:

Get Megacity Multiplayer

To get the Megacity Multiplayer sample, you can clone the project using Git. Please note that direct download of the project is not currently supported for this repository.

Clone the Project

Before you can clone the project, you must install Git Large File Support (LFS). Megacity Multiplayer uses Git LFS to handle all large assets required locally. Refer to Git LFS installation options for instructions on Windows and Mac.

Get Started

After you clone the project, follow these steps to start playing:

  1. Install a compatible Unity Editor version. During install make sure to include Standalone Support and Dedicated Server Support for Windows/Mac.
  2. To add the project to the Unity Hub, click the Add button and select the root folder of the cloned project.
    • Note: The first time you open the project may take longer than usual because Unity is importing all the assets.
  3. Prior to entering playmode, it may be necessary to create the Entities scene cache. To achieve this, please open Main scene located in Scenes/Main.scene.
  1. When all subcenes has been created, open the Menu scene located in Scenes/Menu.
  2. Click the Play button to start.

Main Menu

The main menu offers the following options:

  1. Single Player
  1. Multiplayer, in the "Mode" radio button, you can choose from the following options:
  1. Settings, it is possible to find the option to configure the game settings based on the hardware to enhance your overall gaming experience. This option is also available in the Main scene at runtime.

Run Main scene directly

Setup main scene Within the Resources directory, it is possible to find an asset named MultiplayerServerSettings. This asset allows to configure the Server List that appears in the Menu. Furthermore, there are supplementary options available:

  1. Auto Run Game Mode In Editor Main: This option lets you choose between running the main scene directly in Singleplayer or Multiplayer mode, bypassing the Menu scene.
  2. Auto Run Single Player Game Mode In Editor Main: The availability of this option depends on the selection of "Auto Run Game Mode In Editor Main" as "Single Player." Main Menu

Add Unity Gaming Services (UGS)

Megacity Multiplayer uses several services from UGS to facilitate connectivity between players. To use these services inside your project, you need a Unity Account and create an organization within the Unity Dashboard.

You can still use Megacity Multiplayer without UGS, but for a better multiplayer experience, it is recommended to use the following services:

Game Server Hosting (Multiplay)

Game Server Hosting, formerly known as Multiplay, is a robust and flexible infrastructure for hosting multiplayer games. It ensures a smooth operation of your game by delivering proven performance and scalability. With Game Server Hosting, you can launch your multiplayer titles with confidence, knowing that you have the support of a reliable global platform. The enables you to spend less time troubleshooting and more time building your game with the help of comprehensive documentation, samples, and software development kits (SDKs) designed for interoperability. To get started with Game Server Hosting, refer to the official documentation.

Warning: Game Server Hosting is a pay-as-you-go service with a free tier. You must sign up for UGS services with a credit card to start using Game Server Hosting. If you exceed the free tier usage allowance, you will be charged. See our Billing FAQ to learn more.

To use Game Server Hosting in your project, you need to Integrate the Game Server Hosting service from the Unity Dashboard.

Note: You must be an Owner or Manager of your organization to enable Game Server Hosting.

After you integrate Game Server Hosting, you must create a build, a build configuration, a fleet, and a test allocation.

Tip: Check out our YouTube video How to set up Game Server Hosting.

For Megacity Multiplayer, we use the following Game Server Hosting configuration:

Matchmaker

Matchmaker is a versatile tool that enables you to customize matches in your game. It offers fast and efficient matches, multi-region orchestration, and backfill options. With its flexible configuration, dynamic scalability, and robust rule engine, Matchmaker simplifies matchmaking while supporting complex game loops. For more information, consult the Matchmaker Quick Start Guide.

To use Matchmaker in your project, you must Enable and Integrate the Matchmaker service from the Unity Dashboard.

For Megacity Multiplayer, we use the following Matchmaker configuration:

Creating the queue:

Creating a default pool:

For Matchmaker rules, we use the following configuration:

After configuring the services on the dashboard website, navigate to Edit > Project Settings > Service and choose your organization and project ID.

Project ID

Next, click on the play button to initiate the game. To access the Matchmaking services, navigate to the main menu and select "Matchmake" from the radio button menu, followed by clicking the "Find Match" button.

Selecting Matchmaking

Once the "Find Match" button is clicked, the Matchmaking services will initiate the connection process with the server. During this time, a circular loading indicator will be presented to signify that the system is in the process of establishing the connection. Once the connection is established, you will be able to start gameplay.

Selecting Matchmaking

Vivox

Vivox is a voice chat service that enables players to communicate with each other in-game. To use Vivox, you need to connect your project to Vivox from the Unity Editor and enable Vivox in the Unity Dashboard.

For more information about Vivox, and how to use it you can read the Vivox quickstart guide.

Test Your Multiplayer Setup

Megacity Multiplayer is server-authoritative, which means the server has ultimate authority and control over the game's state and rules. To test the game, a server needs to be running, and clients need to connect to the server. This can be done in the Editor, locally, or through Game Server Hosting (Multiplay).


Connect

Editor Local Multiplayer Setup (Without UGS)

For testing purposes, you can run the Client and Server in the Editor. This enables inspection of entities, systems, components, etc. while running on both the Server and Client.

To set up the Editor for local multiplayer:

  1. Go to Project Settings > Entities.
  2. Set the NetCode Client Target to ClientAndServer.
  3. Open Multiplayer PlayMode Tools from Multiplayer > Window: PlayMode Tools.
  4. Set the PlayMode Type to Client & Server.

In the Assets > Settings > Gameplay > MultiplayerServerSettings, you have the ability to configure a server list that will be presented in the play mode Main menu window. This functionality allows for the establishment of multiple connections and facilitates the use of the Default IP connection.

Setting IP

To begin, click the play button in the Unity Editor to launch the game. Once the game is running and you are in the Main Menu, navigate to the Connect option in the radio button menu. From the drop-down box, select the desired IP address to establish a connection. If the desired IP address is not available in the list, you have the option to create a new entry and re-enter play mode. Alternatively, you can manually enter your own IP address using the provided text field.

Selecting Connect

By default, the project is configured to use the Local IP address. If you are testing the game in the Editor, selecting the Local IP option will allow you to run both the server and client within the Editor, enabling you to play the game.

Once you have selected the appropriate IP address, click the Connect button to initiate the connection process.

Now, when you play the game from the Editor, the Server and Client run together on your local machine. To inspect Client or Server entities, systems, etc., you can use the Entities window (Window > Entities). For example, if you open Entities Hierarchy, you can select the desired World to inspect from the dropdown. See the following image:

Entities Hierarchy


Build Local Multiplayer Setup (Without UGS)

To build your game and test it locally, you need to build the Client and Server separately.

To make a Client Build:

  1. In the Editor, go to Project Settings > Entities to change the NetCode Client Target to Client.
  2. Like any other Unity game, make the build by going to File > Build Settings.
  3. Enable the Megacity scene and set the target platform is Windows, Mac, Linux.
  4. Press the Build button.

Build Settings - Client

To make a Server Build:

  1. Set the target platform to Dedicated Server.
  2. Like the Client build, go to File > Build Settings and press the Build button.

Build Settings - Server


Gameplay Controls

Mouse and Keyboard

InputAction
Mouse Movement / Arrow KeysSteering
Left Click / SpaceShoot
W/SThrust / Reverse
A/DSteering
E/QRoll
TabSettings
VToggle Vivox
PNetcode Panel Stats
No Key PressAuto-Level

Index of Resources in this Project

Gameplay

Audio

Connectivity

Services (Vivox, Matchmaker, etc.)

UI

Tools and Utilities

Troubleshooting

Bugs

Report bugs in Megacity Multiplayer using GitHub issues. If the bugs are related to the Entities packages, use the Entities GitHub issues.

Disclaimer

This repository does not accept pull requests, GitHub review requests, or any other GitHub-hosted issue management requests.

License

Megacity Multiplayer is licensed under the Unity Companion License. See LICENCE for more legal information.