README.md

Megacity Multiplayer

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:

  • Large-scale streaming and rendering with the Entity Component System (ECS for Unity)
  • 64+ players per game session
  • Server-authoritative gameplay with feature prediction, interpolation, and lag compensation using Netcode for Entities
  • Unity Gaming Services (UGS) integration for Game Server Hosting, Matchmaking, and Vivox voice chat
  • High Definition Render Pipeline (HDRP)
  • Cross-platform support for Windows and Mac

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:

  • Operating System: Mac OS X 10.15.7
  • CPU: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  • RAM: 32GB
  • GPU: AMD Radeon Pro Vega 20
  • Storage: 20GB
  • Operating System: Windows 10 64bit
  • CPU: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  • RAM: 32GB
  • GPU: NVIDIA GeForce GTX 1650 with Max-Q Design
  • Storage: 20GB

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:

  • Cloning the Megacity Multiplayer repo: Up to 20 min
  • Opening the project with library build: Up to 20 min
  • When going into the main scene, subscenes need to import: Up to 20 min
  • When going into the playmode, server world is created: Up to 30 min

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.
  • Important: To monitor the progress of the Entities scene cache loading, navigate to Window > General > Process. This action will open the Background Tasks Window, displaying a loading bar. Background Tasks
  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
  • Guided Flight: This mode enables automatic navigation through the city using Cinemachine path to establish the route.
  • Free Flight: In this game mode, you can drive a vehicle and explore the entire city at your own pace.
  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:

  • Launch parameters: -ip $$ip$$ -port $$port$$ -queryport $$query_port$$ -logFile $$log_dir$$/$$timestamp$$-Engine.log
  • CPU Speed: 1500 MHz
  • Memory: 1600 MB

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:

  • Maximum players on a ticket: 12

Creating a default pool:

  • Timeout: 60 seconds

For Matchmaker rules, we use the following configuration:

  • Backfill enabled: true
  • Team count min: 1
  • Team count max: 1
  • Player count min: 64
  • Player count max: 256
  • Relaxation 1: Replace min, Replacement value: 32, at seconds: 5
  • Relaxation 2: Replace min, Replacement value: 1, at seconds: 10

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

Input Action
Mouse Movement / Arrow Keys Steering
Left Click / Space Shoot
W/S Thrust / Reverse
A/D Steering
E/Q Roll
Tab Settings
V Toggle Vivox
P Netcode Panel Stats
No Key Press Auto-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.

File List Total items: 12
Name Last Commit Size Last Modified
.metadata Initial commit 3 months ago
.yamato Initial commit 3 months ago
Assets Merging single-player mechanics [Free Flight | Guided Flight] (#19) 3 months ago
Packages Merging single-player mechanics [Free Flight | Guided Flight] (#19) 3 months ago
ProjectSettings Merging single-player mechanics [Free Flight | Guided Flight] (#19) 3 months ago
Readme Merging single-player mechanics [Free Flight | Guided Flight] (#19) 3 months ago
.gitattributes Initial commit 79 B 3 months ago
.gitignore Cleanup and comment .gitignore (#8) 1.6 KiB 3 months ago
.gitmodules removing template and adding git ignore and attributes 93 B 3 months ago
LICENCE.md adding project settings, documentation, and UI 481 B 3 months ago
README.md Merging single-player mechanics [Free Flight | Guided Flight] (#19) 18 KiB 3 months ago
Third Party Notices.md adding project settings, documentation, and UI 1.6 KiB 3 months ago

Repository Size

Loading repo size...

Commits 29 commits

File Types