Matchmaking functionality

If you want to use the GUI that is supplied with the Asset Store packgage you don't need to worry about any of this as the GUI takes care of connecting to the matchmaking server as well as creating, searching and joining games. To see how to setup your game with the contained GUI see Using the supplied GUI.

If you want to integrate the matchmaking functionallity deeper into your game for example with an own gui you want to use the following functions.

Connecting to matchmaking

Reference your Network controller and attach your network controller to the slot in the inspector:

public NetworkController m_NetworkController;


m_NetworkController.ConnectMatchmaking(host, port);

This returns true if the connection was successfull. The network controller is now connected to your matchmaking server! All the matchmaking features except the offline game are only accessable after the network controller is sucessfully connected to the matchmaking server.

Create a new game

If the network controller is connected to the matchmaking server the player is able to create a new game like this:

m_NetworkController.NewGameOnline(mapName, playerName);

The creates a new game, automatically joins the player to the game and returns true if successfull. At this point you should load your game scene.

Get currently running games

A game is reported as running as long as there is at least one player connected to the game room. To get a string array of the running games run:

string[] games = m_NetworkController.GetGameList();

This returns an array which first element contains the number of currently running games. All following elements contain a string looking like this b5df1e73-bb22-429d-876f-d227ca1e2126;Alrik;Highlands where the first part is the games unique ID which is used to join the game, the name of the player that created the game and the name of the map the game takes place on. If you want to show the games to the player you should seperate them like this:

gameList = new string[games.Length - 1, 2];

for (int i = 1; i < games.Length; i++) {
    string[] gameData = games[i].Split(';');
    m_gameList[i - 1, 0] = gameData[0];
    m_gameList[i - 1, 2] = gameData[1];
    m_gameList[i - 1, 1] = gameData[2];

Now you could for example populate a dropdown menu with these data.

Join a online game

To join a game you need two things. It's unique id and the players name. With these information you can join a game like this:

m_NetworkController.JoinGame(uniqueID, playerName);

This returns true if the player has sucessfully joined the game. You should now load the game scene.

Start new offline game

AwesomeNET makes your life easier by also handling offline games so you don't need to make two versions of all your game code. A offline game is basically a online game with a local server and only one player. You don't need to be connected to any matchmaking server to start a offline game.

m_NetworkController.NewGameOffline(mapName, playerName);

This creates a local game server, connects the player to it and returns true if successfull. You should load your game scene after this.

Further information

The network controller is capable of even more. See the Network Controller Documentation for more features.

Example Matchmaking GUI

To see a commented example implementation of the above mentioned features take a look at the MenuController contained in the asset store packgage.