Megacity Metro 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 Multiplay Hosting.
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:
ClientAndServer
.Client & Server
.In the Assets > Resources > 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.
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, change the mode to Connect in the Menu. From the drop-down box, select the desired server to establish a connection. If the desired server 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.
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 server and 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 > Hierarchy). For example, if you open Entities Hierarchy, you can select the desired World to inspect from the dropdown.
To build your game and test it locally, you need to build the Client and Server separately.
To make a Windows or Mac Client Build:
Client
.iL2CPP
.Main
and Menu
scenes and set the target platform to Windows, Mac, Linux
.To make a Android Client Build:
Client
.iL2CPP
.Main
and Menu
scenes and set the target platform to Android
.To make an iOS Build:
Client
.To make a Server Build: