Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

GameCenter Plugin Live! Leaderboards and Achievements!

Discussion in 'iOS and tvOS' started by prime31, Sep 6, 2010.

  1. hxx2010

    hxx2010

    Joined:
    Aug 31, 2009
    Posts:
    155
    How to get with the given identifier in the list of the scores of their own
     
  2. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @hxx2010, I am not sure exactly what you are looking for. Have you had a look at the documentation? Could it be the GameCenterScore class that you are looking for?
     
  3. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @ratrodstudio, it is almost ready. I have been consumed with the Etcetera plugin. Once it is done it should only take a few days to finish off the uber advanced GC multiplayer system.
     
  4. Hilm

    Hilm

    Joined:
    Nov 2, 2007
    Posts:
    338
    Can't wait for this :D!
     
  5. hxx2010

    hxx2010

    Joined:
    Aug 31, 2009
    Posts:
    155
    How do I get a category in the rankings scores

    Did you know
     
  6. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @hxx2010, you need to setup categories on itunesconnect.apple.com
     
  7. hxx2010

    hxx2010

    Joined:
    Aug 31, 2009
    Posts:
    155
    I have set these
    But also to submit scores of the normal
    My multiplayer games is the rule
    When a player wins a match, then accumulate a points score
    So I have to get past the player's score, and submit scores

    var oldScore : int = ???? //-----how to get a previously uploaded score e
    var newScore : int = oldScore + 1;
    GameCenterBinding.reportScore( newScore, "2" );
     
    Last edited: Oct 17, 2010
  8. kenlem

    kenlem

    Joined:
    Oct 16, 2008
    Posts:
    1,630
    Prime - I just got leader boards to work with your plug in. I went really well except for a typo on my part in the provisioning profile (DOH!)

    Your plugs in are awesome. Nice feature set on the Misc Plugin! That's a must have as well.
     
  9. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @kenlem, glad to hear you got it all working and thanks for the kind words!
     
  10. Moonjump

    Moonjump

    Joined:
    Apr 15, 2010
    Posts:
    2,572
    @Prime31

    My game is looking as if it may end up close to the 20MB 3G download limit, so I am getting rid of whatever I can.

    On my current project I am using the Game Center plugin for High Score tables and Achievements, not for multiplayer. Is it safe to delete all files starting GameCenterMultiplayer in the Editor, Plugins and Prefab folders?
     
  11. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    Absolutely. You will need to be sure to delete the multiplayer methods from the *Binding.cs file as well or else it won't compile.
     
  12. Moonjump

    Moonjump

    Joined:
    Apr 15, 2010
    Posts:
    2,572
    I was going to delete GameCenterMultiplayerBinding.cs as part of the process. GameCenterBinding.cs appears to relate to scores and achievements only, with the exception of retrieveFriends(), so I assume I'll be OK?
     
  13. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @Moonjump, you should be fine. If you see any Xcode errors they should be pretty clear as to what you will need to delete but I believe you will be covering everything with your deletions.
     
  14. stevan

    stevan

    Joined:
    Jul 8, 2009
    Posts:
    10
    I purchased the GameKit plug-in and I am very impressed. I decided to jump into Game Center as well, but the one thing that was holding me back was the lack of group filtering for matchmaking in the original version. It is necessary for my current project. I just want to find out if the group filtering is implemented now in the Game Center plug-in, or a rough date when it would be available.

    Thanks and keep up the great work!

    --Steve
     
  15. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @stevan, if I were forced to give an estimate I would say within the next 7 - 10 days. The update will include player groups and player categories which will then get the Game Center API fully wrapped up.
     
  16. Moonjump

    Moonjump

    Joined:
    Apr 15, 2010
    Posts:
    2,572
    @Prime31, is there a way to get the GC high score for the connected player?
     
  17. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @Moonjump, just use the GameCenterManger.retrieveScores method to grab the scores and see if the player is on the list. You are the only one that can set scores so you can always just keep a local copy around as well. There is a way to get scores for specific playerId's but it isn't implement in the plugin yet.
     
    Last edited: Oct 19, 2010
  18. Moonjump

    Moonjump

    Joined:
    Apr 15, 2010
    Posts:
    2,572
    The high score could have been set on another device, so I cannot rely on having it.

    I was hoping to display the Game Center high score table at the end of a game if the player beats their best. It would be too much to show it every time. I could base it on their best score in their current session, but may just leave it to a menu button so that the player can look when they want.
     
  19. FiveFingers

    FiveFingers

    Joined:
    Oct 15, 2009
    Posts:
    541
    Jashan, OpenFeint 2.7.x supports now 2 ways to go with GameCenter

    - A total conversion toward GameCenter procedure
    - Both way support (this mean your scores will be posted to both OF and GC leaderboards)

    I didn't tested this with Unity3 yet, but if you already have openfeint integrated in your game, this seems the best way to go.

    If its a new game, I'd choose OF anyway, for others, 65$ seems a discreet deal to me.
     
  20. kenlem

    kenlem

    Joined:
    Oct 16, 2008
    Posts:
    1,630
    Argghhh.... I'm having trouble with GameCenter. I was able to authenticate the player and run all the methods in the test scene. Next, I got player auth and leader boards to work in my app. Last night, I was able to post scores and see them in the leaderboards.

    This morning, I try the same app and all I get is "game is not recognized by GameCenter". I've checked my cert, made sure I was using a debug build and everything else I can think of and still no joy. I can't think of anything that I changed.

    I know I haven't posted enough information for anyone to offer a solution. I guess I just wanted to vent.
     
  21. kenlem

    kenlem

    Joined:
    Oct 16, 2008
    Posts:
    1,630
    OK. Not sure this is it but I was trying to login with a sandbox account I created yesterday. Just now, I created a new sandbox user and everything works. I guess I better go back to the Apple docs regarding sandbox users.
     
  22. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @kenlem, the Game Center sandbox is quite fickle. I always make sure to open the Game Center app and log my user out every time before testing. Also be very sure you only use Debug builds (not release) when testing.
     
  23. Moonjump

    Moonjump

    Joined:
    Apr 15, 2010
    Posts:
    2,572
    @Prime31, I got my game to start the player authentication, but it failed. Maybe there was no connection, maybe it was a problem on my side. But I did notice another problem that I am having trouble sorting:

    A notification came up saying authentication failed and did I want to try again. The problem is the game carried on while the notification was blocking the view. I want to pause the game at the point the notification came up. I assume I should use "public static event GameCenterErrorEventHandler playerFailedToAuthenticate;" that is in GameCenterManager.cs, but I'm having trouble with getting the format right. I'm using Javascript. How should I use this?
     
  24. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @Moonjump, you can copy/paste the C# code directly into a Javascript file and it is identical for event handlers. Just open the *EventListener.cs file for examples of every event being subscribed to.
     
  25. Moonjump

    Moonjump

    Joined:
    Apr 15, 2010
    Posts:
    2,572
    I tried copying in:

    Code (csharp):
    1.     void playerFailedToAuthenticate( string error )
    2.     {
    3.         Debug.Log( "playerFailedToAuthenticate: " + error );
    4.     }
    but got 4 errors:

    Assets/Scripts/gameState.js(139,21): UCE0001: ';' expected. Insert a semicolon at the end.
    Assets/Scripts/gameState.js(139,75): BCE0044: expecting ), found 'error'.
    Assets/Scripts/gameState.js(139,81): BCE0043: Unexpected token: ).
    Assets/Scripts/gameState.js(141,68): BCE0044: expecting :, found ';'.

    Line 139 is the "void playerFailedToAuthenticate( string error )" line.

    Playing around with the pasted code failed to solve the problem. I still got 4 errors if I replaced the Debug.Log in your code with the timeScale and Instantiate code in my code below.

    The code I has tried was:

    Code (csharp):
    1.     if (GameCenterManager.playerFailedToAuthenticate()) {
    2.         Time.timeScale = 0.0;
    3.                 Instantiate (pauseMenu);
    4.     }
    It got 1 error:

    Assets/Scripts/gameState.js(134,57): BCE0156: Event 'playerFailedToAuthenticate' can only be triggered from within its declaring type ('GameCenterManager').

    Sorry for this. I am dealing with stuff I haven't dealt with before, and trying to pick it out from a language I haven't dealt with before.
     
  26. kenlem

    kenlem

    Joined:
    Oct 16, 2008
    Posts:
    1,630
    Prime - There is one thing I don't like about the Game Center plug but I'm not sure you can do anything about it.

    I authenticate the player on start up so the first thing you see after the splash screen is my game in the background and the GameCenter login box. The problem is that get the rotating black mask along with the dialog box. I have set the keyboard rotation correctly in Unity but, of course, GameCenter is effected by this. Is there a way in the plug in to set the keyboard rotation so I don't the rotating back outline?

    Thanks.
     
  27. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @kenlem, that rotating black keyboard box has been the bane of my existence for the last month. I wish Unity exposed the code they use for setting up the keyboard view and the game view so I can fix the horrendous support for autorotation. I went as far as just removing it in some tests and wrapping the game view in a proper view controller but without access to their setup code I can't get anything together that is stable enough for production use.

    @Moonjump, I completely forgot to tell you to remote the method parameter types for using the code in Javascript. Change this:

    Code (csharp):
    1.     void playerFailedToAuthenticate( string error )
    2.     {
    3.         Debug.Log( "playerFailedToAuthenticate: " + error );
    4.     }
    to this:

    Code (csharp):
    1.     void playerFailedToAuthenticate( error )
    2.     {
    3.         Debug.Log( "playerFailedToAuthenticate: " + error );
    4.     }
     
  28. eviltenchi_84

    eviltenchi_84

    Joined:
    Feb 18, 2010
    Posts:
    99
    I like to comment out the keyboard line so this is never a problem. Then, things like Facebook and Twitter can activate it only when needed.
     
  29. maglat

    maglat

    Joined:
    Jul 9, 2010
    Posts:
    111
  30. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    Awesome job Maglat! Downloading it right now!
     
  31. Barbur

    Barbur

    Joined:
    Oct 30, 2009
    Posts:
    160
    Hello all,

    A noob question about GameCenter: to test the GameCenter functions into my game do I have to add a new application on itunes connect? Do you use for this a "test" application name? We have a game that is still a bit immature to be added as a new application into itunes and the last time I added an itunes application I had to remove it again due to wrong setup and I could not create it again with the same name :O
     
  32. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @Barbur, you can't do anything at all with GameCenter until you have an app in iTunesConnect to enable it for. Just make a test app and when you are ready to release make a real one with the proper name.
     
  33. spentak

    spentak

    Joined:
    Feb 11, 2010
    Posts:
    246
    I'm having some difficulty understanding the way to design a simple multiplayer game.

    What I'm trying to do:

    Simple 2 player "fighting" type game. Player 1 presses "Attack". We then call ReceiveAttack(int attackPoints) on player 2. I understand all the logic behind making my game function. The thing i'm unsure of is how do we reference player 2 (3,4, etc). Is there a step by step tutorial on using Game Center plugin (not just the invite features) but the sending of data etc.?

    Thanks,
    Mark
     
  34. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @mark, check out the second sample scene (GameCenterMultiplayerTestScene.unity) that is in the GameCenter Plugin unitypackage. It will show you how to connect 2 or more devices over the network and send messages back and forth.
     
  35. spentak

    spentak

    Joined:
    Feb 11, 2010
    Posts:
    246
    So it looks like this is the thing i'm looking for:
    GameCenterMultiplayerBinding.sendMessageToAllPeers( "GCTestObject", "receiveTime", Time.timeSinceLevelLoad.ToString(), false );

    What is the argument "Parameter" for? Is it the parameter for the method that is called? If so, I can use any type?

    Also:
    This is what I really need: sendMessageToPeers - The first argument is playerIds[] - At what point did we find the other players id and where did we store it?
     
    Last edited: Oct 26, 2010
  36. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @mark, have a look at the available events in the multiplayer portion of the docs. Some of the events that may be useful for you to listen to from the GameCenterMultiplayerManager class are:

    - playerConnected
    - playerDisconnected

    The sendMessage* methods allow you to call a function on a game object with a given parameter. In the example from your post, the GCTestObject GameObjects receiveTime function would be called with Time.timeSinceLevelLoad.ToString(). Very much like this:

    someHandleToGCTestObject.receiveTime( Time.timeSinceLevelLoad.ToString() )
     
  37. mforsyth

    mforsyth

    Joined:
    Sep 29, 2010
    Posts:
    54
    I have a game in iTunes Connect with gamecenter enabled, I have logged out current gamecenter account. The dev built game starts up and asks for someone to log in "Sign In" "use existing account" "create new account" or "cancel". So I log in, then all I get is a gamecenter window saying "This game is not recognized by Game Center."
    out of my game and into gamecenter, I log in and view account, I see "SANDBOX (1L52)" at the top.

    Starting game already logged in, and I get the "This game is not recognized by Game Center."

    I'm not sure how to test, tried creating a new gamecenter account but verification emails are down so I'm stuck with my previous account.

    ***update - fixed for now*
    so, in iTunes Connect, under Manage Apps, under app's icon, blue button 'View Details' for Versions, scroll down to Game Center and make sure the button next to it is green and says Enabled for this version.
    Then my next oops, not using my bundle id found on that same page but the longer string from the developers site. not '3DE65FGF43.com.company.app', but use just 'com.company.app'

    my login screen has never said ***SANDBOX***, just log in.

    ***update 2.0 working?
    I see a 'welcome back blah' inside the game, seems to be working. but when I check inside gamecenter app and look at the list of games this user is playing, it lists the wrong one! ?!?!?!
    It's listing another temporary app that had gamecenter enabled, but doesn't now, and has been deleted from itunesconnect. my bundle identifier is correct to the game I'm trying to use.
     
    Last edited: Oct 28, 2010
  38. kenlem

    kenlem

    Joined:
    Oct 16, 2008
    Posts:
    1,630
    I had similar problems with my game. First, make sure you're signing with the correct cert. Second, clean everything and build again.

    I also included the test scenes in my app and used those to ensure I could log in and such then I rebuilt my game with my level as the first.

     
  39. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    nice but the prices are too steep for some things :)
     
  40. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @hippocoder, if the prices are too steep you aren't valuing your own time enough :) The prices are a *steal* for the amount of time saved.
     
  41. spentak

    spentak

    Joined:
    Feb 11, 2010
    Posts:
    246
    I can't seem to find the method that calls for a "log in" pop up to appear. For instance, the game loads, we authenticate player, player is not authenticated- I want the pop up that says "Use existing account" "create new account" "cancel". Where might i find this?
     
  42. kenlem

    kenlem

    Joined:
    Oct 16, 2008
    Posts:
    1,630
    I'm sorry. Which plug is priced too high?
     
  43. spentak

    spentak

    Joined:
    Feb 11, 2010
    Posts:
    246
    I need help with this.

    So I've just added a new game center enabled app on itunes connect. I made temporary descriptions and uploaded temp images. I created a new app ID for the test game. I enabled game center, then added leader boards and achievements.
    I uploaded no binary.

    At this point i don't know what to do. How do i go from where I am to testing the game with 2 people on sandbox?


    Also, on another note: I can't seem to find where to implement player groups. I have 2 modes, "Standard" and "Special". If the user presses "Standard" we programatically find players ONLY who are also searching for a "Standard" game and vice versa. Thanks
     
    Last edited: Oct 27, 2010
  44. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @marklennartprice, be sure you read through all the Apple docs on setting up Game Center. Follow them very closely. Be sure to setup test users and follow the tips in the plugin docs. You don't have to setup player groups or player attributes. Have a look at the 'Advanced Matchmaking Topics' from Apple's docs for more information on player groups and attributes.
     
  45. spentak

    spentak

    Joined:
    Feb 11, 2010
    Posts:
    246
    I am unsure how to use this effectively:

    Code (csharp):
    1. public void matchmakerFoundMatchWithExpectedPlayerCount( string playerCount )
    2.     {
    3.         int expectedPlayerCount = int.Parse( playerCount );
    4.         if( matchmakerFoundMatch != null )
    5.             matchmakerFoundMatch( expectedPlayerCount );
    6.     }
    I would think that this would return a bool? Meaning, if the player count min has been met return true.

    I don't understand what all of the delegates and events are for. Also what is an Event listener for?

    How do I simply get a true bool value when the player count minimum is reached, or if the match has started, etc?

    I am simply trying to figure out when I can load my multiplayer scene, but that needs to happen after the minimum player count has been met. I don't know how to get data from the events/delegates.
     
    Last edited: Oct 27, 2010
  46. robhuhn

    robhuhn

    Joined:
    Jun 21, 2009
    Posts:
    113
    Hi, first of all great work! The implementation and configuration is pretty easy.

    Now I have an issue with the orientation. I have set the app-orientation in unity to landscape left and I dont get the keyboard black edges. But when I start the app and hold the iPhone in landscape right position, the unity view still shows up in landscape left (it is flipped from my point of view) and the authentication bar is landcape right orientated. The same happens with the leaderboard view. So GC is allways orientated like the iPhone orientation. And that is what I want to prevent. I want to have the app-orientation left at any iPhone-rotation.

    Is there a way to realize that?

    I tried this but it didnt affect anything
    Code (csharp):
    1.  
    2. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    3.     // Return YES for supported orientations
    4.     return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
    5. }
    6.  
     
  47. bmahloch

    bmahloch

    Joined:
    Apr 16, 2010
    Posts:
    20
    Just purchased the plugin, works great!

    One thing I did notice is that "retrieveScores" does not allow you to specify a category. In my case I have 3 leaderboard categories and want to retrieve scores from a specific category. I was able to update the plugin to include the categoryId on the retrieveScores method and all is working great now. Thought it may be useful to have this added to the product.
     
  48. spentak

    spentak

    Joined:
    Feb 11, 2010
    Posts:
    246
    I'm really struggling here to figure this plugin out.

    Here is my code:

    Code (csharp):
    1. public static void QuickMatch()
    2.     {
    3.         //Start a game with 2 player minimum and maximum
    4.         GameCenterMultiplayerBinding.findMatchProgrammaticallyWithMinMaxPlayers(2,2);  
    5.     }
    All I want to know is what do I do next exactly. We are in the lobby scene. This method is called. I need to know exactly what method I call now to figure out when the other player has been found so I can load the proper scene. I really need help with this.

    Thanks much,

    Mark
     
  49. kenlem

    kenlem

    Joined:
    Oct 16, 2008
    Posts:
    1,630
    Are you watching for events to complete?
     
  50. spentak

    spentak

    Joined:
    Feb 11, 2010
    Posts:
    246
    See that is what i'm missing. I don't know how to check when an event has completed. Delegates and events are new to me