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. rextr09

    rextr09

    Joined:
    Dec 22, 2011
    Posts:
    416
    Hi, I have added GC easily with your plugin, thanks for that. But I have a weird problem. I have 3 Game Center accounts. Lets say user1, user2 and user3.
    - Yesterday I post score with user1 and still shows empty leaderboard.
    - Today I post score with user2 and it shows both user1 and user2 on the leaderboard, perfect.
    - Then, I post score with user3 and it shows only user1 and user3 on the leaderboard.

    Then, I login with user1, still empty leaderboard
    Then, I login with user2, it shows only user1 and user2.

    What am I missing? Is there anything wrong with the accounts? Thanks in advance.
     
  2. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @rex, this topic comes up at least once per week in this thread and we have a huge note about it in the documentation (see screenshot below). Please be sure to read the documentation as it contains as much important information as we can squeeze into a tiny space. We purposely strip it down to the bare minimum with the hopes that folks will actually read it.

     
  3. rextr09

    rextr09

    Joined:
    Dec 22, 2011
    Posts:
    416
    I have read the docs and that note, but since user2 can see user1's scores, I thought there is another problem. Anyway, you say that some time later user1 can also see the leaderbord, right?

    Btw, this issue is only available in Sandbox environment right? Or is it same on live GC too?
     
    Last edited: Sep 6, 2012
  4. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @rextr, it is only in the sandbox. Apple has many sandbox servers and they do not stay in sync.
     
  5. rextr09

    rextr09

    Joined:
    Dec 22, 2011
    Posts:
    416
    Oh, thanks.. Another question... When the game released, is it okay to continue with the current (test) leaderboard, or should be create a blank new leatherboard? Does Apple care about it during the approval process?
     
  6. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @rextr, per Apple's documentation you shouldn't be making any test leaderboards. The only leaderboards that you should be making are those that are fit for production and will be released with your game.
     
  7. rextr09

    rextr09

    Joined:
    Dec 22, 2011
    Posts:
    416
    @prime31, thanks for the quick replies, I appreciate it.

    PS: I have just deleted the "unused" leaderboards before Apple see them :)
     
  8. franktinsley

    franktinsley

    Joined:
    Jul 1, 2010
    Posts:
    130
    So I'm able to send and receive single messages using GameCenterMultiplayerBinding.sendMessageToAllPeers but I'm running into a lot of unpredictable behavior when those received messages call local methods that in turn send another message. Is there some reason messages can't be sent immediately due to receiving a message?
     
  9. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @frank, it is an open socket connection so when you send shouldn't matter. We've built stuff that sends at least one message per frame in an Update function without any issues. There will of course be latency to deal with but that is normal for online multiplayer.
     
  10. franktinsley

    franktinsley

    Joined:
    Jul 1, 2010
    Posts:
    130
    Okay I finally found where my issues were coming from. I just wasn't entirely understanding how to properly use the api and some of the code around the messages had really dumb mistakes in it, as I guessed was probably the issue. All is working! Thanks for the awesome plugins!
     
  11. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    For the folks out there struggling with iOS 6 and Unity compatibility with regard to orientation outlined here is a quick fix until Unity gets an update released.

    - set the orientation setting in the Unity player settings to the following:


    - open the iPhone_View.mm file and add the following method after the line "@implementation UnityViewController":

    Code (csharp):
    1. - (BOOL)isOrientationSupported:(UIInterfaceOrientation)orientation
    2. {
    3.     EnabledOrientation targetAutorot = kAutorotateToPortrait;
    4.     ConvertToUnityScreenOrientation( orientation, &targetAutorot );
    5.    
    6.     return UnityIsOrientationEnabled( targetAutorot );
    7. }
    - open the AppController.mm file and add the following line in the application:didFinishLaunchingWithOptions: method right before the "return NO" line:

    Code (csharp):
    1. [UIApplication sharedApplication].keyWindow.rootViewController = UnityGetGLViewController();
    - add the following method in the AppController declaration:

    Code (csharp):
    1. - (NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window
    2. {
    3.     NSUInteger supportedOrientations = 0;
    4.    
    5.     UnityViewController *vc = (UnityViewController*)UnityGetGLViewController();
    6.    
    7.     if( [vc isOrientationSupported:UIInterfaceOrientationPortrait] )
    8.         supportedOrientations |= (1 << UIInterfaceOrientationPortrait);
    9.    
    10.     if( [vc isOrientationSupported:UIInterfaceOrientationPortraitUpsideDown] )
    11.         supportedOrientations |= (1 << UIInterfaceOrientationPortraitUpsideDown);
    12.    
    13.     if( [vc isOrientationSupported:UIInterfaceOrientationLandscapeLeft] )
    14.         supportedOrientations |= (1 << UIInterfaceOrientationLandscapeLeft);
    15.    
    16.     if( [vc isOrientationSupported:UIInterfaceOrientationLandscapeRight] )
    17.         supportedOrientations |= (1 << UIInterfaceOrientationLandscapeRight);
    18.  
    19.     return supportedOrientations;
    20. }
    The final AppController changes will look like this:


    This will fix the crash but it will also allow your game to rotate to portrait (which isn't desirable for a landscape game). This is easily remedied by calling "Screen.autorotateToPortrait = false;" at app launch. The trick here is to call "Screen.autorotateToPortrait = true;" BEFORE authenticating the local player! That will allow the login screen to display (Apple only support portrait for some reason). Once the player is authenticated you can call "Screen.autorotateToPortrait = false;" to keep your game in landscape.


    Edit: oops. The screenshot has a typo for the UIInterfaceOrientationPortraitUpsideDown statement. See the text for the proper code.
     
    Last edited: Sep 16, 2012
  12. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    Important note: we will be off the grid with no cellular or internet access and unable to respond until September 27th. In the meantime read the documentation and check back through the forum posts to locate an answer to your question.
     
  13. MythicalCity

    MythicalCity

    Joined:
    Feb 10, 2011
    Posts:
    420
    I just released a game and had the same auto-rotation issue on iOS 6 devices. Tried the above instructions and others from other forum posts, but none worked correctly. My project doesn't even contain an iPhone_View.mm file, so I made those changes to the AppController and got some warnings.

    Instead of trying to go with one of these quick fixes, I just ended up using TimeMachine to restore an older version of Xcode (4.4.1) and that completely fixed the issue. So if you don't need iOS 6 SDK or the latest Xcode, restore your old Xcode and re build the game. Of course, I'll have to wait and see if apple approves this fix. Arghhhh, I wonder how many 1 star reviews the game will get now :(
     
  14. camilo_otro

    camilo_otro

    Joined:
    Sep 27, 2012
    Posts:
    1
    Hi everyone,

    I'm currently implementing turnbased multiplayer for my game using the prime 31 plugin, so far it's been very easy to use, and it's worked perfectly, I am able to crate matches, send turns back and forth between the players, and get turn notifications loading the proper match. I've started to test the match end functionality and I've run into this error message after making a call to endMatchInTurnWithMatchData and sending the final gamestate as a byte array.

    Code (csharp):
    1. Error Domain=GKErrorDomain Code=17 "The requested operations could not be completed because one or
    2. more parameters are invalid." UserInfo=0xee71e10
    I've set the outcome of the match for all players as suggested by the apple documentation, but I don't know if I have to make any additional call to make sure that the outcome has been saved for all players on the GameCenter side.

    Any help would be greatly appreciated.
     
  15. J_P_

    J_P_

    Joined:
    Jan 9, 2010
    Posts:
    1,027
    I got it working today without any issues.

    GameCenterTurnBasedBinding.setMatchOutcomeForParticipant(GKTurnBasedMatchOutcome.Won, playerId1);
     
  16. J_P_

    J_P_

    Joined:
    Jan 9, 2010
    Posts:
    1,027
    For turn based multiplayer, is there really not an easy way to grab a participant's game center username? Do I have to do it through LoadPlayerData?
     
  17. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @jtown, loadPlayerData is the only way to load a users info
     
  18. J_P_

    J_P_

    Joined:
    Jan 9, 2010
    Posts:
    1,027
  19. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @jtown, it is already in the next update but there is no ETA at the moment.
     
  20. junksnakes

    junksnakes

    Joined:
    Jul 19, 2012
    Posts:
    2
    Hey Prime,

    I've used the Turn Based plugin in a few projects, but this time I'm getting the error "Warning: Attempt to present <GKTurnBasedMatchmakerViewController: 0xbb376b0> on UnityViewController_IOS6: 0x1f39940> while a presentation is in progress!" and then no input is accepted. Any idea what I might be doing wrong?

    Edit: Nevermind, it seems that the problem came from calling findMatch within Update instead of OnGUI.
     
    Last edited: Oct 2, 2012
  21. Wild-Factor

    Wild-Factor

    Joined:
    Oct 11, 2010
    Posts:
    607
    Hi prime 31.
    When I call GameCenterBinding.showLeaderboardWithTimeScope( GameCenterLeaderboardTimeScope.Week );
    it only show the leaderboard of the first level.

    Is it possible to show the screen of the list of all leaderboard ?

    thanks
     
  22. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @wild, iOS 4 and 5 do not support showing the leaderboard list. It is only available in iOS 6 and we haven't come up with a clean way to pull it off that is somewhat backwards compatibile.
     
  23. schwertfisch

    schwertfisch

    Joined:
    Sep 7, 2010
    Posts:
    126
    Hello, the last time I used your GC plugin on my previous game, it was GameCenter_2011-07-29.unitypackage. Now that I'm ready to publish my new game I reopened the purchase email to download the latest version and the link that you had sent me last year gives me GameCenterMultiplayer_2012-09-09.unitypackage. What I want though is the latest version of the GameCenter package, not the multiplayer one. If there is one newer than my GameCenter_2011-07-29.unitypackage, could you please send me a download link?

    Thank you,
    Alexis Michail,
    Kavala, Greece
     
  24. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @schwert, send an email to questions (at) prime31.com from the email address that you have on file with PayPal and we'll resend your purchase receipts.
     
  25. Benderlab

    Benderlab

    Joined:
    Sep 18, 2012
    Posts:
    8
    Hi, Prime31

    I have one question about latest update GC plugin.

    When I call showLeaderboardWithTimeScopeAndLeaderboard( GameCenterLeaderboardTimeScope timeScope, string leaderboardId ), my main menu music stops playing. In previous version of plugin this problem has been solved by comment line UnityPause( true ); in Xcode
    But now I found only libGameCenterPlugin.a and P31MonoBridge.h
    Can I get it not to stop playing music while GC Leaderboard activated?

    Thanks for your support!
     
  26. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @bender, Unity is fully paused while showing any GC views. Having Unity running while a GC view is shown results in really bad scrolling performance.
     
  27. G_Koko

    G_Koko

    Joined:
    Aug 25, 2012
    Posts:
    30
    Hi! I'm trying to retrieve my friends list, their scores and picture but I don't know in what var, array or hash it is saved. I'm using:
    GameCenterBinding.retrieveFriends(true)
    What am I missing?
     
  28. The Bag

    The Bag

    Joined:
    May 28, 2012
    Posts:
    24
    Hi Prime, can you advise about how to match make turn based matches for a specific game mode? From what I can see in Apple's docs GKTurnBasedMatchmakerViewController, which I assume is what you're using with GameCenterTurnBasedBinding.findMatch, takes a GKMatchRequest object which allows the specification of a playerGroup variable which could be used for this purpose.

    I notice in the Game Center Multiplayer plugin (non turn-based) that this is supported via showMatchmakerWithFilters, is there a reason these extra paramaters aren't exposed for the turn based plugin? Is this something that can be added?
     
  29. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @G_koko, retrieveFriends sends a request to get the frieds list. The following event will fire with the information once loaded:

    Code (csharp):
    1. // Fired when player data is loaded after requesting friends
    2. public static event Action<List<GameCenterPlayer>> playerDataLoaded;

    @thebag, player groups currently arent supported in the turned based plugin. The next update will have player groups exposed.
     
  30. The Bag

    The Bag

    Joined:
    May 28, 2012
    Posts:
    24
    @Prime, that's great. Any idea when the next update will drop?
     
  31. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @thebag, nope. We don't provide ETA's for releases. Too many things can happen to cause delays.
     
  32. BooBi

    BooBi

    Joined:
    Jan 18, 2010
    Posts:
    534
    Hi,

    I'm using the Gamecenter plugin, when I use the GameCenterBinding.loadLeaderboardTitles(); The list leaderboard created comes with a completely random order (not in the order of the gamecenter leaderboards, neither alphabetical,...) (always the same order tho).

    Why is it like that ? What can I do to have them in the same order of my gamecenter leaderboards ?

    Thanks a lot for the help.
     
    Last edited: Nov 6, 2012
  33. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @boo, we return them exactly the same way Apple returns them. If you want to sort them you can do so on the Unity side any way you want.
     
  34. BooBi

    BooBi

    Joined:
    Jan 18, 2010
    Posts:
    534
    ok thanks a lot ;) Great plug-ins BTW, I did facebook twitter last weekend and now I'm doing the Game center integration for my game. Really helpful and straightforward!
     
  35. BooBi

    BooBi

    Joined:
    Jan 18, 2010
    Posts:
    534
    In fact another question, today I connected everything with the leaderboards and I post scores, tomorrow I'm going to retrieve the scores to use them in my own gui leaderboards.
    I'll need to import the top 5 of all my leaderboards into a 2d array WorldScores[numberOfLeaderboards][5].

    What is the easiest way to do that ? I'll use the retrieveScores() function but where will it import the scores? Sorry I haven't investigate that part much yet.

    Thanks a lot for your time and help.
     
    Last edited: Oct 18, 2012
  36. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @boo, calling retrieveScores sends the request to Apples servers to fetch the scores. The scoresLoaded event will then fire with a List of all the scores once loaded.
     
  37. BooBi

    BooBi

    Joined:
    Jan 18, 2010
    Posts:
    534
    thank you very much!
     
  38. cjow

    cjow

    Joined:
    Feb 29, 2012
    Posts:
    132
    Hey,

    I've just installed GameCenter plugin and immediately there's a problem building in Xcode. All I have done so far is import the package and then build. Here is the error that Xcode generates:



    If I remove the plugin and build again the problem goes so I'm positive that it is the plugin that is causing it but I'm at a loss as to why. Any help or explanation would be deeply appreciated.

    Thanks.
     
    Last edited: Oct 19, 2012
  39. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @cjow, armv6 support has been dropped. Set your Unity settings to armv7 only and it will build.
     
  40. cjow

    cjow

    Joined:
    Feb 29, 2012
    Posts:
    132
    Cheers. I was just about to do that then I logged off and booted my Windows PC instead xD. Oh well back and forth. Thanks for the response.
     
  41. TheDoc

    TheDoc

    Joined:
    Oct 23, 2012
    Posts:
    2
    Is there a replacement method in the latest GameCenter plugin for:

    showLeaderboardWithTimeScopeAndCategory() ?

    Is it

    showLeaderboardWithTimeScopeAndLeaderboard() ?
     
    Last edited: Oct 23, 2012
  42. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @thedoc, it is showLeaderboardWithTimeScopeAndLeaderboard
     
  43. blindgoat

    blindgoat

    Joined:
    Oct 24, 2012
    Posts:
    31
    I'm trying to load profile pictures of buddies. I correctly receive pictures for buddies who have them. However, some of my buddies don't have a picture and I received the error "profilePhotoFailed: The requested operation could not be completed due to an error communicating with the server." Is this normal? I was expecting a default picture or an error message that says they don't have a picture :p.

    If this is normal and not just a result of sandbox mode, do you have any suggestions for knowing which user this error is referring to? I want to give them a default picture if they don't have one but this error tells me nothing about the user. I can just wait x seconds and loop through my friends and give all that don't have a pic the default one, but it seems like there should be a better way.

    I'm simply calling GameCenterBinding.retrieveFriends(true).
     
    Last edited: Oct 24, 2012
  44. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @blind, if there is no profile photo GameCenter will indeed return that error. We will look into adding the playerId to the error message for easier identification in the next update.
     
  45. blindgoat

    blindgoat

    Joined:
    Oct 24, 2012
    Posts:
    31
    @prime - thanks for the help earlier.

    Random question for anyone:

    I have two GC accounts that were created in sandbox mode. I set a picture for each of them and they are buddies. I request my buddy list and receive the picture for the buddy... but it's empty. It's 0KB picture.

    My process:
    userA and userB are GC friends in sandbox mode.
    userA: logs into GC in sandbox mode and sets picture
    userB: logs into app and requests photo from Apple servers and get a response that the photo loaded.

    The problem: The photo's size is 0 and obviously doesn't display anything when I try using it.

    When I have a buddy who does NOT have a photo, the servers respond with the network error, as expected (see Prime's post one above this). This guy has a photo but the photo I get has nothing in it.

    Is this something I'm doing incorrectly or is it expected behavior in the sandbox? If it's sandbox behavior, how do you test that your code to display the pics is working properly?

    I've posted this on the iOS dev forums as well... I'll update either one when I figure it out. Thanks!
     
  46. G_Koko

    G_Koko

    Joined:
    Aug 25, 2012
    Posts:
    30
    Hi Prime,

    I´m trying to get the Game Center scores from a player using GameCenterBinding.retrieveScoresForPlayerId and is working well, on Xcode I can see the data and that the event is trigger only once, however, the value is repeating the same number of friends that the user has when I try to save the score inside the event GameCenterManager.scoresForPlayerIdLoaded ( I checked the list.Count for this event and always gives me 1 ).

    To clarify, if I have 4 friends, the value is printed/saved 4 times instead of only once. Any idea why is happening this? ( just in case, before calling GameCenterBinding.retrieveScoresForPlayerId, I use GameCenterBinding.retrieveFriends to save the ID´s and is working well )

    Thanks in advance!
     
  47. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @G_Koko, if an event is firing 4 times that is an indicator that you subscribed to it 4 times. Every time you use the += operator you have to balance it with a -= call.
     
  48. blindgoat

    blindgoat

    Joined:
    Oct 24, 2012
    Posts:
    31
    Has anyone been able to get GC profile photos to load and display in sandbox mode? If so, would you mind a brief explanation of how? Thanks!
     
  49. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @blind, whenever you load any player data you can optionally load profile images. For each image loaded the following event will fire:

    // Fired when the profile image is loaded for the player and includes the full path to the image
    public static event Action<string> profilePhotoLoaded;
     
  50. dream000

    dream000

    Joined:
    Oct 5, 2011
    Posts:
    26
    Hello Prime,
    We recently purchased GameCenter and GameCenter Multiplayer plugins. I tested multiplayer plugin's test scene using ipad2 with ios 6 and ipad with ios 5. The playerconnected event is not getting fired on ipad2 (ios 6). But the same event is getting fired in ios 5. What may be probable cause?