Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

[Solved] How to do match making?

Discussion in 'Multiplayer' started by KungFooMasta, Aug 8, 2015.

  1. KungFooMasta

    KungFooMasta

    Joined:
    May 27, 2014
    Posts:
    24
    First off, yes I am referencing the manual:
    http://docs.unity3d.com/Manual/UNetMatchMaker.html

    One of the errors I got directed me to https://multiplayer.unity3d.com. So I went here, I signed in, and I created a project called "Bounty Hunters". The only configuration I see for my project is "Max Player Count", which is default set to 15. Trying to change it and set it to 10 doesn't seem to work, it re-displays 15.

    I'm not sure what a "Cloud Project Id" is or where to get it, but I assume its the name of the project I just created on multiplayer.unity3d.com, so I set that in my Player Settings. (File -> Build Settings -> Player Settings)

    When I run my application, I get a lot of output:

    MatchMakingClient Create :https://mm.unet.unity3d.com/json/reply/CreateMatchRequest

    System.FormatException: FAILURE Returned from server: Failed CreateMatch for appId=0
    at UnityEngine.Networking.Match.Response.Parse (System.Object obj) [0x0003e] in

    JSON Response: [[UnityEngine.Networking.Match.CreateMatchResponse]-success:False-extendedInfo:Failed CreateMatch for appId=0]-address:,port:0,networkId:0x0000000000000000,nodeId:0x0000,usingRelay:False
    UnityEngine.Networking.Match.<ProcessMatchResponse>c__Iterator0`1:MoveNext()​

    My code follows from the sample:

    Code (CSharp):
    1.             Log.Add ("Creating Match Request.. Match Name: {0}", "bkinsey");
    2.  
    3.             CreateMatchRequest request = new CreateMatchRequest ();
    4.             request.name = "bkinsey";
    5.             request.size = hunt.NumHunters;
    6.             request.advertise = (filter != PartyFilter.Private);
    7.             request.password = string.Empty;
    8.  
    9.             mNetworkMatch.CreateMatch (request, OnMatchCreated);
    QUESTIONS:
    1. Why is my appId 0, do I need to explicitly set this? (If so, where do I get my appID from?)
    2. Is it normal that the Multiplayer config for my project only shows "Max Player Count", which cannot be updated? (I do not have a pro account, is it required?)
     
  2. KungFooMasta

    KungFooMasta

    Joined:
    May 27, 2014
    Posts:
    24
    Did some more looking around and saw a different URL: https://unet.cloud.unity3d.com

    Went here, looks like the same page I went to previously, except now my project configurations had some important details, I saw my actual Cloud Project ID, which looks like a GUID. I entered that into the player settings, and I get a different set of results.. but still failed.

    MatchMakingClient Create :https://mm.unet.unity3d.com/json/reply/CreateMatchRequest

    System.FormatException: FAILURE Returned from server: Failed CreateMatch for appId=201701
    at UnityEngine.Networking.Match.Response.Parse (System.Object obj) [0x0003e] in C:\buildslave\unity\build\Runtime\Networking\Managed\UNETInterface.cs:214
    at UnityEngine.Networking.Match.CreateMatchResponse.Parse (System.Object obj) [0x00000] in C:\buildslave\unity\build\Runtime\Networking\Managed\UNETInterface.cs:322​

    In this thread its suggested that I explicitly set the program app ID, which is supposedly the UNET ID listed on my project's configuration page, however I see my UNET ID is already being used in the error message above.

    http://forum.unity3d.com/threads/unet-sample-projects.331978/

    Am I experiencing some transient issues with the match making service, or am I missing something?
     
  3. KungFooMasta

    KungFooMasta

    Joined:
    May 27, 2014
    Posts:
    24
    Solved!

    There are a couple issues I found out the hard way:
    1. The name of the room doesn't accept certain characters, in my case the < and > characters caused the match creation to fail.
    2. Not able to create a match with size of 1? I thought the goal is to be able to use networking solution for single and multiplayer. Now I have to create a match with minimum size of 2.. which means I'll have to generate some password so nobody else can join, and hope nobody randomly guesses the match name and password.
     
  4. JeremyUnity

    JeremyUnity

    Joined:
    Mar 4, 2014
    Posts:
    147
    Hi KungFooMasta,
    What's the reason you'd want to create a match size of 1? You can just avoid connecting to the matchmaker if no one is allowed to join and avoid debiting the CCU credit.
     
  5. KungFooMasta

    KungFooMasta

    Joined:
    May 27, 2014
    Posts:
    24
    With my latest project I decided to make a multiplayer game, and since everything is new to me, I'm not sure what the best design is. I read in the manual that we should be able to implement a single player game such that its a multiplayer game with 1 person. I also don't understand what CCU is, but I know matchmaking is a Unity service and I had to create a cloud project where the match making service is currently in beta or something.

    Basically my game will have these 3 scenarios:
    1. Single player, playing against AI. (single player hack and slash)
    2. Multiplayer, playing in a party against AI. (group of hack and slash players fighting together)
    3. Multiplayer, playing in a party against AI and another party. (2 groups of hack and slash players fighting each other)

    My understanding is that matchmaking is how people can find each other to play with or against right? So I will need this for scenarios 2 and 3 above. But for scenario 1, I guess I need to just skip the match making part, but implement the game as a host with no remote clients, right?

    Scenarios in networking terms:
    1. No matchmaking, Host with no remote clients
    2. Matchmaking, Host with several remote clients
    3. Matchmaking, Host with several remote clients

    I guess I still need to understand how a match and a host are related, to be able to start a game with just the local client who hosts his own game vs. a game where match making has provided several remote clients, they signal they are ready, and the leader hosts the game.

    Also, does Unity provide some mechanism around usernames? For example, how can I ensure that all users have unique names? For example, messaging a particular user, or trying to join a particular user's game. Right now I'm creating a match using the creator's username, but not sure how to enforce unique names. Seems like it would be a common requirement right?
     
  6. KungFooMasta

    KungFooMasta

    Joined:
    May 27, 2014
    Posts:
    24
    How can I tell if I am a host or a client? For example when creating a match, I use StartHost(matchInfo), and when I join a match I use StartClient(matchInfo). But when I quit the match, If I am the host, I should call StopHost(), right? Looking at the code it looks like I can just call StopHost regardless of being a host or not, and it will clean everything up. But it's probably not the intended solution since there is a StopClient API, right?

    Just to clarify from my above post, I believe the 3 scenarios are like this:
    1. StartHost();
    2. StartHost(matchInfo); // Given MatchResponse from successful match creation
    3. StartClient(matchInfo); // Given MatchResponse from successfully joining a match
     
    Last edited: Aug 17, 2015