Results 1 to 9 of 9
  1. #1
    MSgt. Shooter Person
    Join Date
    Jan 2011
    Posts
    104

    Default [Tut] ish .. Networking - Multiplayer - game center

    Ignore this , all issues in this post have been resolved

    Hi,
    I've got 2 iOS devices, both logged into game center in my game but now I'm stuck... I've read through all the docs at udn but now I'm not sure what to do first. I understand replication and how it works my problem is I don't understand how the players join eachother in a game in the first place ?

    I get that showmatchmakingUI will take care of chosing who is the server and sending a URL to clients so they can join a server but then I don't know what to do with the create and client delegates ? The client delegate I presume I just call a clientTravel to get it to join the sever but what about the create delegate? Do I need to call anything specific or just clientTravel to a map and the clients will magically join me there. I can't find any examples of these delegates in use so I'm stuck.

    If anyone could point me in the right direction I'd appreciate it. A tutorial would be even better, just something as simple as getting 2 players on a plain map together would be awesome.

    If anyone is having probs getting as far as their iOS device/devices logging onto gamecenter with sandbox accounts let me know and I'll at least get you that far using May ( June and July seem to be broken )

    Thanks for taking the time to read this.

    rOb
    Last edited by insanerob; 08-18-2011 at 08:11 AM.

  2. #2

    Default

    Hi,

    I haven't even got as far as you, so if you could help me with getting connected to gamecenter, I'd much appreciate it, and if I make any further progress I could let you know.

    SC

  3. #3

    Default

    Hi,

    Here is the code I've used for a successful networked game connection between a client and server. Hope it helps

    Code:
    // These don't need to be filled in with data but they cannot be None or ShowMatchmakingUI will crash
    var OnlineGameSearch SearchSettings;
    var OnlineGameSettings GameSettings;
    
    simulated event PostBeginPlay()
    {
        super.PostBeginPlay();
        SearchSettings = new class'OnlineGameSearch';
        GameSettings = new class'OnlineGameSettings';
    }
    
    
    function ClearCreateOnlineGameDelegates()
    {
        OnlineSub.GameInterface.ClearCreateOnlineGameCompleteDelegate(OnCreateOnlineGameComplete);
    }
    function OnCreateOnlineGameComplete(name SessionName,bool bWasSuccessful)
    {
        local string URL;
        if(!bWasSuccessful) {
            ClearCreateOnlineGameDelegates();
            return;
        }
    
        URL = "map01" $ "?game=MyGame.MyDeathmatch" $ "?listen";
        ClientTravel(URL, TRAVEL_Absolute);
    
        ClearCreateOnlineGameDelegates();
    }
    
    
    function ClearJoinOnlineDelegates()
    {
        OnlineSub.GameInterface.ClearJoinOnlineGameCompleteDelegate(OnInviteJoinComplete);
    }
    function OnJoinOnlineGameComplete(name SessionName,bool bWasSuccessful)
    {
        local string URL;
    
        if(!bWasSuccessful || OnlineSub == none || OnlineSub.GameInterface == none ) {
            ClearJoinOnlineDelegates();
            return;
        }
    
        if (OnlineSub.GameInterface.GetResolvedConnectString(SessionName,URL))
        {
            // allow game to override
            URL = ModifyClientURL(URL);
    
            `Log("Resulting url is ("$URL$")");
            // Open a network connection to it
            ClientTravel(URL, TRAVEL_Absolute);
        }
        ClearJoinOnlineDelegates();
    }
    
    function OpenNativeMatchmakingUI()
    {
        local OnlineSuppliedUIInterface OSI;
    
        if(OnlineSub == none)
            OnlineSub = class'GameEngine'.static.GetOnlineSubsystem();
    
        if(OnlineSub == none) 
            return;
    
        if(OnlineSub.GameInterface == none)
            return;
    
        OSI = OnlineSuppliedUIInterface(OnlineSub.GetNamedInterface('SuppliedUI'));
        if (OSI == none)
            return;
    
        OnlineSub.GameInterface.AddCreateOnlineGameCompleteDelegate(OnCreateOnlineGameComplete);
        OnlineSub.GameInterface.AddJoinOnlineGameCompleteDelegate(OnInviteJoinComplete);
        OSI.ShowMatchmakingUI(0,SearchSettings, GameSettings);
    }

  4. #4
    MSgt. Shooter Person
    Join Date
    Jan 2011
    Posts
    104

    Default Here's the bit to get you on GC before you start adding code

    krussell beat me to a response and to be fair his code is prettier than mine

    Thought I'd add the bits that need to be in place before you get as far as adding the code.

    1, Use May build ... June / July GC doesn't work for us

    2, First you need to get your iOS provisioning stuff in place : Go onto your Apple Dev - Provisioning Portal ( unless you did it right the first time ),
    a, Create a new AppId for your game. Even though it will say GC enabled you'll need to do a bit more to get it to work .
    b, Create a new Provisioning profile for you game using the AppId you just created , tick your cert and add the devices you will be testing on. Submit the cert and download it.

    3, Now you need to tell iTunes and GameCenter about your App .
    a, Browse to itunes connect - itunesconnect.apple.com and log in with your Apple Dev account info
    b, click the link to Manage Your Applications
    c, Add New App
    d, App Name - Title of Your Game e.g. Monkey Ninjas from Uranus blah blah
    - SKU Number - essential a revision number of the app that meant something to you .... e.g. 01
    - Bundle ID - Select the App ID you created earlier
    ... fill in all the rest of the stuff regarding categories , contact etc.
    Click Manage Game Center - Enable multiplayer
    e, Make a note of the Bundle Identifier !!
    N.B. Don't upload your game - Leave it in a status of 'prepare for upload' .. you only upload when you are ready to release the game.

    4, IPhoneEngine.ini set bDisableGameCenter=false .... once this is in place when you load your game on an iOS device it will fire up gamecenter as it loads


    N.B. make sure that you add this to your Engine ini files and that it gets propagated to your ini files when you compile / package as OnlineSubsystemGameCenter is not packaged by default
    [UnrealEd.EditorEngine]
    +EditPackages=OnlineSubsystemGameCenter

    5, In UnrealFrontend / Application Settings / Already a registered iOS developer - add the new mobileProvision you created in step 2b . In the Info plist make sure you use the bundle identifier as it appears in iTunes connect step 3e ... if you get it wrong you'll get a message as you load the game saying Application not recognized

    6, install your app on your iDevice using frontend.

    7, Log out of game center and then fire up the app on your iDevice. This is important as you will need to create a sandbox GC account for testing games, you can't use live GC accounts. You should see the familiar GC screen during the initial Epic splash movie as your game loads. Create a new account when prompted, this will automatically create a sandbox account rather than a regular account. Log in with your new sandbox account.

    8, You've now got Game Center working ....hopefully ... from here on it's up to you, you can add leaderboards / achievements ( see chickencoop code ) and multiplayer ( see krussels code ) .

    N.B. Remember that if you are testing multiplayer it needs to be the same build on each device so after you've deployed your current build to the first device, for any subsequent devices just use the 'deploy to iOS' option in unrealfrontend.

    ..... don't panic if you see GC return 127.0.0.1 as a URL in code to your clients ... it's normal , it is looping back into GKMatch on your iPhone

    .... if you have problems with getting multiplayer to connect on wifi then you may need to setup port forwarding on your router ... just google Apple Game Center Ports

    Big thanks to Krussell for the neat code thus saving me tidying mine and Trendy for Chicken coop code

    rOb
    Last edited by insanerob; 09-28-2011 at 03:15 AM.

  5. #5

    Default

    Thanks for that, will be very helpful (working on integrating it now).

    Thought I should add that I noticed once you have added you app to the app store as per (3) above, you have 120 days to upload a version or you will lose the name forever.

    So if your final game project is likely to have a 4 month dev time or more, you might want to use a different name during development.

  6. #6

    Default

    Hey everybody!

    I'm looking to implement a semi-multiplayer mode that is more like turn based than real time. I can't seem to find how to just send messages between devices that can be picked up when that device logs on. I guess that would be an unreliable message according to the apple documentation (I'm also assuming unreliable is another name for UDP-style connection...or at least similar). The idea is that the game doesn't start with all the players, I just need to connect and share information on who the players are and then disconnect and use messages to send any further data. Could somebody point me in the direction of a site, forum, or wiki that may help? Thanks!

  7. #7
    Prisoner 849
    Join Date
    Mar 2011
    Location
    U.S.
    Posts
    877
    Gamer IDs

    Gamertag: ICHAINSAWDURMOM

    Default

    Just curious, but did you put this example code in it's own class or did you put it in the custom gameinfo class?

  8. #8
    Prisoner 849
    Join Date
    Mar 2011
    Location
    U.S.
    Posts
    877
    Gamer IDs

    Gamertag: ICHAINSAWDURMOM

    Default

    Quote Originally Posted by Krussell View Post
    Hi,

    Here is the code I've used for a successful networked game connection between a client and server. Hope it helps

    Code:
    // These don't need to be filled in with data but they cannot be None or ShowMatchmakingUI will crash
    var OnlineGameSearch SearchSettings;
    var OnlineGameSettings GameSettings;
    
    simulated event PostBeginPlay()
    {
        super.PostBeginPlay();
        SearchSettings = new class'OnlineGameSearch';
        GameSettings = new class'OnlineGameSettings';
    }
    
    
    function ClearCreateOnlineGameDelegates()
    {
        OnlineSub.GameInterface.ClearCreateOnlineGameCompleteDelegate(OnCreateOnlineGameComplete);
    }
    function OnCreateOnlineGameComplete(name SessionName,bool bWasSuccessful)
    {
        local string URL;
        if(!bWasSuccessful) {
            ClearCreateOnlineGameDelegates();
            return;
        }
    
        URL = "map01" $ "?game=MyGame.MyDeathmatch" $ "?listen";
        ClientTravel(URL, TRAVEL_Absolute);
    
        ClearCreateOnlineGameDelegates();
    }
    
    
    function ClearJoinOnlineDelegates()
    {
        OnlineSub.GameInterface.ClearJoinOnlineGameCompleteDelegate(OnInviteJoinComplete);
    }
    function OnJoinOnlineGameComplete(name SessionName,bool bWasSuccessful)
    {
        local string URL;
    
        if(!bWasSuccessful || OnlineSub == none || OnlineSub.GameInterface == none ) {
            ClearJoinOnlineDelegates();
            return;
        }
    
        if (OnlineSub.GameInterface.GetResolvedConnectString(SessionName,URL))
        {
            // allow game to override
            URL = ModifyClientURL(URL);
    
            `Log("Resulting url is ("$URL$")");
            // Open a network connection to it
            ClientTravel(URL, TRAVEL_Absolute);
        }
        ClearJoinOnlineDelegates();
    }
    
    function OpenNativeMatchmakingUI()
    {
        local OnlineSuppliedUIInterface OSI;
    
        if(OnlineSub == none)
            OnlineSub = class'GameEngine'.static.GetOnlineSubsystem();
    
        if(OnlineSub == none) 
            return;
    
        if(OnlineSub.GameInterface == none)
            return;
    
        OSI = OnlineSuppliedUIInterface(OnlineSub.GetNamedInterface('SuppliedUI'));
        if (OSI == none)
            return;
    
        OnlineSub.GameInterface.AddCreateOnlineGameCompleteDelegate(OnCreateOnlineGameComplete);
        OnlineSub.GameInterface.AddJoinOnlineGameCompleteDelegate(OnInviteJoinComplete);
        OSI.ShowMatchmakingUI(0,SearchSettings, GameSettings);
    }
    Can anyone confirm if this should go in it's own class or coupled with an already existing class. I have no way to test this code yet because I don't have an iDevice or a developers license yet, but I want to get this in place for the time being.

  9. #9
    MSgt. Shooter Person
    Join Date
    Jan 2011
    Posts
    104

    Default

    Hi ,
    My GC code is in my playerController which is extended from GamePlayerController, seemed the logical place to put it

    hope it helps

    rOb


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.