Legacy Documentation: Version 5.5
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

NetworkMatch.CreateMatch

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public function CreateMatch(matchName: string, matchSize: uint, matchAdvertise: bool, matchPassword: string, publicClientAddress: string, privateClientAddress: string, eloScoreForMatch: int, requestDomain: int, callback: DataResponseDelegate<MatchInfo>): Coroutine;
public Coroutine CreateMatch(string matchName, uint matchSize, bool matchAdvertise, string matchPassword, string publicClientAddress, string privateClientAddress, int eloScoreForMatch, int requestDomain, DataResponseDelegate<MatchInfo> callback);

Parameters

matchName The text string describing the name for this match.
matchSize When creating a match, the matchmaker will use either this value, or the maximum size you have configured online at https://multiplayer.unity3d.com, whichever is lower. This way you can specify different match sizes for a particular game, but still maintain an overall size limit in the online control panel.
matchAdvertise A bool indicating if this match should be available in NetworkMatch.ListMatches results.
matchPassword A text string indicating if this match is password protected. If it is, all clients trying to join this match must supply the correct match password.
publicClientAddress The optional public client address. This value is stored on the matchmaker and given to clients listing matches. It is intended to be a network address for connecting to this client directly over the internet. This value will only be present if a publicly available address is known, and direct connection is supported by the matchmaker.
privateClientAddress The optional private client address. This value is stored on the matchmaker and given to clients listing matches. It is intended to be a network address for connecting to this client directly on a local area network. This value will only be present if direct connection is supported by the matchmaker. This may be an empty string and it will not affect the ability to interface with matchmaker or use relay server.
eloScoreForMatch The Elo score for the client hosting the match being created. If this number is set on all clients to indicate relative skill level, this number is used to return matches ordered by those that are most suitable for play given a listing player's skill level. This may be 0 on all clients, which would disable any Elo calculations in the MatchMaker.
requestDomain The request domain for this request. Only requests in the same domain can interface with each other. For example if a NetworkMatch.CreateMatch is made with domain 1, only ListMatches that also specify domain 1 will find that match. Use this value to silo different (possibly incompatible) client versions.
callback The callback to be called when this function completes. This will be called regardless of whether the function succeeds or fails.

Returns

Coroutine This function is asynchronous and will complete at some point in the future, when the coroutine has finished communicating with the service backend.

Description

Use this function to create a new match. The client which calls this function becomes the host of the match.

When creating a match you should call this function and wait for the callback to be invoked before proceeding. The callback will indicate if the call was successful as well as extended information if it failed. After receiving the response callback you then should call StartHost() with the passed in MatchInfo.

no example available in JavaScript
          NetworkMatch matchMaker;
...
matchMaker.CreateMatch("roomName", 4, true, "", "", "", 0, 0, OnMatchCreate);

public void OnMatchCreate(bool success, string extendedInfo, MatchInfo matchInfo) { ... }