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

    scinfu

    Joined:
    Oct 23, 2008
    Posts:
    404
    what is it public delegate void ScoresLoadedEventHandler( List<GameCenterScore> scores ); and how to use ?

    i trying to post the score of all players and compare it ..
     
  2. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @scinfu, a delegate is used when custom events are fired. Have a look at this article for more information. If you look at the *EventListener file you will see examples for listening to all the available events.
     
  3. scinfu

    scinfu

    Joined:
    Oct 23, 2008
    Posts:
    404
    thank you
     
  4. karn9872

    karn9872

    Joined:
    Sep 26, 2010
    Posts:
    14
    Just downloaded the plugin and opened the test scene, but received this compile error:
    Assets/Editor/Prime31/P31MenuItem.cs(44,21): error CS0117: `Process' does not contain a definition for `Start'

    I'll keep experimenting to try to find a solution. Any idea what this is? This happens for all the Game Center test scenes.
     
  5. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    You can safely delete the P31MenuItem.cs file. It isn't required by the plugin to operate.
     
  6. VPrime

    VPrime

    Joined:
    Mar 4, 2009
    Posts:
    74
    I am interested in getting this plugin, but just wondering one thing before I do.
    Is it possible to get the players highest score from the leaderboard?
    I would just need the score returned so I can output to the player his personal best to beat.

    Possible?
    Thanks.
     
  7. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @VPrime, there is no direct way to specifically ask for the players highest score. You can use the retrieveScoresForPlayerId method to get all the scores then just filter out the one you are looking for.
     
  8. VPrime

    VPrime

    Joined:
    Mar 4, 2009
    Posts:
    74
    Ok figured as much.
    What is returned when call the method? Is it just some integers/strings? Or does it load up a game center window?
     
  9. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @VPrime, like most of the GameCenter methods it is async so you will need to listen to the appropriate events. The *EventListener.cd file has examples of every available event.
     
  10. karn9872

    karn9872

    Joined:
    Sep 26, 2010
    Posts:
    14
    Everything is working great so far. I have 1 problem when trying to build and run on the simulator though:

    Code (csharp):
    1. mono_dl_register_symbol("_gameCenterIsGameCenterAvailable", (void*)_gameCenterIsGameCenterAvailable);
    2. .../XCode/Libraries/RegisterMonoModules.cpp:84:0
    3. error: 'mono_dl_register_symbol' was not declared in this scope
    4.  
    Any idea if it is possible to run this code in the simulator? I'm trying to test a multiplayer game so I needed the extra simulator device.
     
  11. kenlem

    kenlem

    Joined:
    Oct 16, 2008
    Posts:
    1,630
    No, you can't use the simulator. You'll need another device.
     
  12. eviltenchi_84

    eviltenchi_84

    Joined:
    Feb 18, 2010
    Posts:
    99
    will the plugin run fine on the ipad now that 4.2 is out?
     
  13. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @eviltenchi_84, as far as I know there are already games out there using it for 4.2. It was 4.2 ready from the start. There does appear to be a couple orientation bugs with the iPad and I would like to play around with it to see if maybe using different modal presentation style would make for a nicer experience. The orientation issues are going to be a beast to fix until Unity pulls their game view into a view controller proper but with a bit of hacketry it should be useable.
     
  14. eviltenchi_84

    eviltenchi_84

    Joined:
    Feb 18, 2010
    Posts:
    99
    cool, thanks for the info
     
  15. Moonjump

    Moonjump

    Joined:
    Apr 15, 2010
    Posts:
    2,572
    My game TiltStorm is 4.2 and has been on the App Store for nearly a week. Another Unity developer has been playing it without problem on his iPad that has the 4.2 beta on it.
     
  16. ezone

    ezone

    Joined:
    Mar 28, 2008
    Posts:
    331
    That makes sense - it looks like TiltStorm is a portrait game, the orientation issue only affects iPad landscape games.

    If you need any help with testing Prime31, just let me know!
     
  17. bmahloch

    bmahloch

    Joined:
    Apr 16, 2010
    Posts:
    20
    @Prime31

    I noticed when calling "retrieveScores" with friendsOnly = true and the currently authenticated user having 0 friends that a response is never returned. After debugging the plugin I noticed the call to [leaderboardRequest loadScoresWithCompletionHandler] does not produce an error and the scores array is nil. There is currently no code path to handle no error with a nil scores array so no callback is triggered on the Unity side. In my case I just added an "else" that passes through an empty array via UnitySendMessage. Maybe a plugin update?

    Thanks!
     
  18. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @bmahloch, grab the latest update and it should return an empty set for scores now when there are none.
     
  19. prankard

    prankard

    Joined:
    Mar 24, 2010
    Posts:
    19
    Also having the issues with iPad. Testing the leaderboard alert view pulls in portrait and then goes out landscape when I have my project set to:

    Code (csharp):
    1. application.statusBarOrientation = UIInterfaceOrientationLandscapeRight;
    On the iPhone 4, runs perfect in landscape.

    Please have a hack around and try to fix the orientation issues, it would be much appreciated here!

    Otherwise, the plugin works great. Very happy to see everything else working great :)
     
  20. ezone

    ezone

    Joined:
    Mar 28, 2008
    Posts:
    331
    +1 (just waiting on the fix so we can submit a holiday app update!)
     
  21. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    The iPad orientation hack should be ready shortly. My iPad had to get dropped back to 3.2 for some plugin backwards compatibility testing. As soon as I get that complete and get 4.2 installed again this is first on my list.
     
  22. mindlube

    mindlube

    Joined:
    Oct 3, 2008
    Posts:
    993
    Howdy, a question for Prime31, and for the community.

    Has anyone managed to get these plugins to compile in XCode 4 Preview** ?
    I am getting tons of linker errors it seems maybe I don't have the right SDKs installed.

    I just bought the iAds and GameCenter plugins from prime31 today. Do I need to download additional SDKs from Apple as well?

    ** (reason for using XCode 4 preview : LLVM compiler for iOS/ARM devices is supposed to be pretty awesome) . This is the future of iOS compilation. People are already building and shipping production apps with LLVM, so I have read.
    http://developer.apple.com/technologies/tools/whats-new.html#llvm-compiler
     
  23. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    I haven't played with Xcode 4 since preview 2 and will not be able to speak of or support Xcode 4 until it reaches GM and the NDA is lifted. You can still use LLVM in Xcode 3 but honestly I don't think you are going to get any advantage whatsoever with Unity seeing as how it is running in the Mono VM which is preconpiled.
     
  24. mindlube

    mindlube

    Joined:
    Oct 3, 2008
    Posts:
    993
    Mike / Prime31:
    OK sounds good- I hadn't thought of that. I'll stick with the XCode 3 (XCode 3.2.5 and iOS SDK 4.2 should be the correct platform for now, right?)
    Thanks,
    Alex
     
  25. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    Sounds about right to me.
     
  26. ezone

    ezone

    Joined:
    Mar 28, 2008
    Posts:
    331
    Thanks Prime - awesome customer support as always!
     
  27. karn9872

    karn9872

    Joined:
    Sep 26, 2010
    Posts:
    14
    Thanks kenlem and Prime31 for your answers.

    Multiplayer is now working, but voice chat is not. I installed the Multiplayer test scene to figure out what was wrong and the chat does not work there on my 2 devices. I have a 2nd gen iPod Touch (iOS 4.2) with no mic and a 4th gen iPod Touch (iOS 4.1). I speak into the 4th gen device and playerBeganSpeaking is never triggered on either device. Both are on a WiFi connection and display "true" for isVOIPAllowed. The mic works using Skype so I know that is not the problem. Is it not working because of the 2nd gen device?

    Less importantly, when a multiplayer match is established "matchmakerFoundMatch" returns with "matchmakerFoundMatch with expected player count: 0" and "playerConnected" is not called when I use the "showMatchmaker..." function calls. It is called properly after "findMatchProgrammatically...". Is this normal behaviour? I don't really care because sendMessage works fine after matchmakerFoundMatch is called and I just broadcast the player IDs manually to each device.
     
  28. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @karn, my iPod touch 2G won't voice chat unless I have headphones with a mic plugged in. I am not 100% sure if that is the intended behaviour. There are no Apple provided docs that detail how each device should behave.
     
  29. karn9872

    karn9872

    Joined:
    Sep 26, 2010
    Posts:
    14
    Thanks, Prime. That is probably the issue.
     
  30. killerham

    killerham

    Joined:
    Jun 4, 2010
    Posts:
    21
    I'm trying to build this using the test scene and xcode gives me a whole bunch of errors that deal with GKFriendRequestComposeViewController. How do I fix this?

    here is an error that pops up a few times:
    Cannot find protocol declaration for 'GKFriendRequestComposeViewControllerDelegate'

    also, what am I to change in the info.plist?
     
  31. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @killerham, be sure to set your Base SDK to 4.2 and that will clear up the errors.
     
  32. killerham

    killerham

    Joined:
    Jun 4, 2010
    Posts:
    21
    Thanks, that worked
     
  33. killerham

    killerham

    Joined:
    Jun 4, 2010
    Posts:
    21
    Ok I got it to build, but I don't understand how to use this.
    I built the game in deug mode, and when I click authorize I create an account..
    On iTunes connect I am using the same buildID that I have set inside of Unity.

    I am getting the error "This game is not recognized by game center".
     
  34. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @killerham, make sure you follow the tips and tricks in the docs to the letter. Be sure to fully log out of the official Game Center app, always use a debug build (set in Xcode), double check your bundle Id (with proper appId) and make sure you are setup for Game Center in iTunesConnect.
     
  35. killerham

    killerham

    Joined:
    Jun 4, 2010
    Posts:
    21
    what do you mean by check the bundle Id with app id? the app id is just numbers
     
  36. VPrime

    VPrime

    Joined:
    Mar 4, 2009
    Posts:
    74
    Posting on behalf of killerham:
    He got the plugin to work.
     
  37. VPrime

    VPrime

    Joined:
    Mar 4, 2009
    Posts:
    74
    Is it possible to bring up a game center screen similar to the games page in the game center app itself?
    Right now we are calling
    Code (csharp):
    1. public static void showLeaderboardWithTimeScope( GameCenterLeaderboardTimeScope timeScope )
    Butt hat only brings up a score list for the default category. Is it possible to bring up a screen similar to the "game" screen inside of the game center app? (so it lits the leader boards, achievements and recently played?)

    This is the screen I would like to call.. possible?
     
  38. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @Vprime, you can only bring up the achievements or leaderboards. There are no other built in UIs available.
     
  39. killerham

    killerham

    Joined:
    Jun 4, 2010
    Posts:
    21
    I have the same code running on my 3g and my 4g, why does game center pop on 3g?
     
  40. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
  41. killerham

    killerham

    Joined:
    Jun 4, 2010
    Posts:
    21
    It isn't, that why I'm wondering why it pops up on my 3g
     
  42. prankard

    prankard

    Joined:
    Mar 24, 2010
    Posts:
    19
    Thanks :) Again, much appreciated.
     
  43. Barbur

    Barbur

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

    I am having a problem with the playerConnected delegate. I need to receive the event when a player has been connected to a match but I never receive it. Anyone has had this problem and solved it? I also need to get the alias of the connected players... I tried to find some function for this with no luck :O
     
  44. robhuhn

    robhuhn

    Joined:
    Jun 21, 2009
    Posts:
    113
    Hi,

    I just noticed that an alert box comes in which says 'Game Center Disabled - Sign in with the Game Center application to enable.' after I canceled the authentication process three times. After that alert I don't get the login dialog anymore - as expected - but I either get the alert described above. It only dispatches an authentication failed event with a common error message. Comes this behavior from GC itself or the Plugin? Is there a way to show the 'Game Center Disabled'-message over and over?

    And my second question is if there's a way to bring in a GC-banner like 'Welcome back ...' when the player completed an achievement?

    Thanks in advance
     
    Last edited: Nov 29, 2010
  45. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @Barbur, try the playerConnected and playerDisconnected events and the loadPlayerData function for getting player aliases from their id's

    @Rubhun, the behaviour you are seeing is from GC itself. There is no way to gain control of it. GC doesn't have achievement banners so you will need to make those yourself.
     
  46. Curious

    Curious

    Joined:
    Nov 19, 2009
    Posts:
    334
    @Prime31:
    Hi Mike,
    I tried integrating GameCenter using you plug-in, this is the first time I'm having trouble using your plug-ins! ;)

    It gives me errors about GameCenterMultiplayer! 19 error actually! I've set-up GC in my account, I am compiling the app in Debug mode, and I don't need multi-player right now! I'm using Unity 3.1 + iOS 4.1 + your plug-in (the version before iOS 4.2)
    iPhone only, SDK ver.4.1, Target iOS.3.0

    Am I missing something?! I can't even build! Do you want me to post the errors?

    Thank you in advance

    [EDIT]
    Here're the errors I get:

     
    Last edited: Nov 30, 2010
  47. robhuhn

    robhuhn

    Joined:
    Jun 21, 2009
    Posts:
    113
    thanks for your reply.

    How do you or anyone else here handle those cases? I mean you wouldn't show nothing if the player wants to login or you wouldn't show a common error-message every time the player cancels the login process would you?
     
  48. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @Curious, you just need to set your Base SDK to 4.2 and the errors will disappear.

    @Robhuhn, what I have seen most often is to simply not show leaderboard/achievement buttons if the user chose not to login or entered invalid credentials.
     
  49. Curious

    Curious

    Joined:
    Nov 19, 2009
    Posts:
    334
    Thank you Mike, will check it out, that ought to be it ;)

    Regards
     
  50. eviltenchi_84

    eviltenchi_84

    Joined:
    Feb 18, 2010
    Posts:
    99
    is it possible to use gamecenter to do a third person shooter multiplayer mode? Basically, is sendMessageToAllPeers sufficicent to keep updating all players constantly since they are moving and shooting at each other? Also, gamecenter is run through apple's servers so are they going to allow a more intensive game like this or will they possibly ban us from their servers? (don't want to have to use our own server)