- Home /
Question by
ibrahim_khan · Oct 29, 2016 at 03:51 PM ·
unity 5networkinghud
unable to find list of matches created on unity relay server
I am a UNET beginner . I am customizing network manager HUD to achieve following functionality
if( matches.Count == 0 )
{
//create a new match
//and wait for someone to join
} else
{
//join the first match in matches list
}
i am trying to achieve this functionality in this way but every time this code creates a new match and can not find already created match -thanks in advance please help if any one knows - -findmatch is triggered by a button at start
public class NetworkCtrl : NetworkManager
{
public void Start()
{
StartMatchMaker();
}
public void findMatch()
{
matchMaker.ListMatches(0, 20, "**", true, 0, 0, OnMatchList);
}
public override void OnMatchList(bool success, string extendedInfo, List<MatchInfoSnapshot> matchList)
{
base.OnMatchList(success, extendedInfo, matchList);
if (success)
{
if (matches.Count != 0)
{ // some one already created a match so join that match
joinMatch(matches[0].networkId);
label.text = "joining found matches";
}
else
{
// no match exists so create a match and wait for someone to join
createMatch();
label.text = "creating new match";
}
}
}
public void createMatch()
{
matchMaker.CreateMatch("", 2, true, "", "", "", 0, 0, OnMatchCreate);
}
public void joinMatch(NetworkID netId)
{
matchMaker.JoinMatch(netId, "", "", "", 0, 0, OnMatchJoined);
}
}
Comment
Your answer
Follow this Question
Related Questions
How to use NetworkManager.ServerChangeScene ? 1 Answer
Spaw dynamic (unregistered) object on network (UNET) 0 Answers
how do you send commands from objects that dont have "Authortiy" unet 1 Answer
can't switching between weapons in multiplayer game? 0 Answers
Network Transport Layer API does not work with iOS to PC? 1 Answer