Giter VIP home page Giter VIP logo

lvshiling / megacitymultiplayer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from unity-technologies/megacity-sample

0.0 0.0 0.0 89.58 MB

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.

License: Other

C# 90.35% HLSL 1.43% ShaderLab 8.22%

megacitymultiplayer's Introduction

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:

  • 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:

Recommended Specs for Mac

  • 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

Recommended Specs for Windows 10

  • 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. Open the Megacity scene located in Scenes/Megacity. The first time you open the scene, tt may take longer to load the Subscenes.
  4. Click the Play button to start.

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).


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.

megacitymultiplayer's People

Contributors

julianunity avatar diegoossa avatar mathiasjensen90 avatar repodb[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.