GameCenter Plugin Live! Leaderboards and Achievements!

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

  1. Joe ByDesign

    Joe ByDesign

    New Member

    Joined:
    Oct 13, 2005
    Messages:
    841
    Your preference is noted, and sure our devs could spend more time and wrap your code, however, given the fact you're making Unity Plugins for Unity developers wishing to save time from manually doing the same, means you should put your personal preference aside and instead develop them consistent with Unity.

    If you were making XCode plugins, it would be a different story.

    my 0.02! :)
     
  2. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @getluky, be absolutely sure you are following the note in the docs. You have to be using a debug build and you must log out of Game Center through the official Game Center app before testing. You also must be sure your app is Game Center enabled in iTunes Connect and that your bundle identifier is properly setup in Unity.
     
  3. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @Joe @ ByDesign Games, technically, they are Xcode plugins or at least that is where 90+ percent of the code is! :D
     
  4. Joe ByDesign

    Joe ByDesign

    New Member

    Joined:
    Oct 13, 2005
    Messages:
    841
    ...and made for Unity :)

    All passengers get off at Unity :)

    Adding, your own sig makes my point! haha :) :)
     
  5. langju

    langju

    New Member

    Joined:
    Jul 1, 2009
    Messages:
    207
    @prime31

    I've compiled on my iPhone a code using the plugin, but would like to test the multiplayer.
    Can I try using th iphone simulator ?

    Indeed, it seems that it doesn't compile if i choose debug simulator + BAse SDK and target SDK to ios 4.1 ?
     
  6. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @langju, I doubt that it will work in the simulator. Unity just tacked on very basic simulator support for the iPad for before it came out. It doesn't seem that they are trying to add full simulator support at this time. You will need two devices to do your testing.
     
  7. impla007

    impla007

    New Member

    Joined:
    Jan 30, 2010
    Messages:
    57
    @langju, I didn't succeed either to get the simulator working. I had my app working in the sim with 3.1.3 or 3.2 but not with 4.1.
     
  8. langju

    langju

    New Member

    Joined:
    Jul 1, 2009
    Messages:
    207
    ok so, will have to test with a second device
    (cannot use the 3.1 because of the Gamecenter support needed)

    thanks anyway for your help
     
  9. goodhustle

    goodhustle

    New Member

    Joined:
    Jun 4, 2009
    Messages:
    310
    @Prime31, I double, triple, and quadruple tried all of those suggestions, but still no dice. Bundle ID is correct. App has GameCenter enabled on iTunes Connect. Active target is set to Debug build. I logged out and logged in through the debug build several times, but got the same error.

    I'm on Unity iPhone 1.7 Pro. The only other thing I can think of is if you need to upload a binary to iTunes connect first - I haven't done so yet as this is for an unreleased game. Does that matter at all?

    Is there a "SANDBOX" message in the login dialogue if it's trying to connect to the sandbox? Is there any other way to check and see if it's trying to connect to production?
     
  10. langju

    langju

    New Member

    Joined:
    Jul 1, 2009
    Messages:
    207
    when compiling in the simulator, here is the result ( 2 errors only :)

    any idea eventually ? (this is using U3b7....)
     

    Attached Files:

  11. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @getluky, here is a thread on the devforums with the same issue you are having. It looks like what worked for the user on the thread was fully deleting the app from the device then reinstalling. Try calling some other methods like retrieving friends and leaderboards and see what the debugger logs just to be certain.


    @langju, it looks to me like Unity didn't add support for registering plugins on the simulator.
     
  12. langju

    langju

    New Member

    Joined:
    Jul 1, 2009
    Messages:
    207
    If you check the first screen of the gamecenter, it will be written the Pseudo of your sandbox account.
     
  13. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @langju, can you provide a screenshot? I have never seen evidence of sandbox vs. live servers and it would have saved me a ton of time to have known while testing. I don't see anything indicating sandbox on my phone...
     
  14. langju

    langju

    New Member

    Joined:
    Jul 1, 2009
    Messages:
    207
    I mean I have 2 accounts in fact using the same email.
    the first time i have opened the "True" Gamecenter, i have registered with the pseudo "langju".

    When i have purchased the pluging :
    i have logged out from the True GameCenter.

    I have opened the demo scene of the plugin and clicked "Authenticate", i have then created a new account (but with the same email and password than the one of the True GameCenter) with the pseudo ixgaming.
    now I can check if i am connected on the SandBox or the True Gamecenter just by checking which pseudo is appearing on the main screen.

    So when you connect/ deconnect it is written from where you de/connect "GameCenter" or "SandBox"

    I send the screenshot ....
     
  15. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @langju, sweet. I had no idea you could setup test and real Game Center accounts with the same email. Thanks for the tip!
     
  16. langju

    langju

    New Member

    Joined:
    Jul 1, 2009
    Messages:
    207
    I mean I have 2 accounts in fact using the same email.
    the first time i have opened the "True" Gamecenter, i have registered with the pseudo "langju".

    When i have purchased the pluging :
    i have logged out from the True GameCenter.

    I have opened the demo scene of the plugin and clicked "Authenticate", i have then created a new account (but with the same email and password than the one of the True GameCenter) with the pseudo ixgaming.
    now I can check if i am connected on the SandBox or the True Gamecenter just by checking which pseudo is appearing on the main screen.

    So when you connect/ deconnect it is written from where you de/connect "GameCenter" or "SandBox"

    I send the screenshot ....
     

    Attached Files:

  17. goodhustle

    goodhustle

    New Member

    Joined:
    Jun 4, 2009
    Messages:
    310
    OK, I found the problem. I had enabled GameCenter on the Manage Your Applications section of iTunes Connect, but I also had to go down into View Details for my specific 1.0 App Version and enable GameCenter there. It seems like I still don't get "Sandbox" on the login screen like I do on the GKTapper sample project, so I'm not sure what's up with that, but it looks like I can continue the experimentation now. Thanks for the help, @Prime31, and I hope this helps anyone else running into the same issue.
     
  18. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    OK, so to add to all this in the official Game Center app just tap your name and in the popup tap 'View Account'. You will see if you are in the sandbox or not just as langju said. See the screenshot below.
     

    Attached Files:

  19. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @impla007, I just tested and you can use the generic lists from Javascript as if they are just normal arrays. For example:

    Code (csharp):
    1. var someList = getSomeList();
    2. someList[1];
     
  20. bumba

    bumba

    New Member

    Joined:
    Oct 10, 2008
    Messages:
    358
    is it possible to setup several leaderboards for a game?

    Is it possible to rank the lowest score first?
     
  21. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @bumba, I believe the upper limit is 30 leaderboards but best check the docs to be certain. Each leader board can be sorted whichever way you see fit.
     
  22. impla007

    impla007

    New Member

    Joined:
    Jan 30, 2010
    Messages:
    57
    Thanks for your support Prime, .I had problems because I was forcing the type of var someList. But the way you do it works fine. Thanks. Your plugin as well as you support are excellent.

    :D
     
  23. sboyette

    sboyette

    New Member

    Joined:
    Jan 22, 2009
    Messages:
    62
    Prime,

    I will be picking this up today, thanks! Any plans for adding voice to the kit?

    --Never Mind, sorry I just saw it! (thanks!)


    Thanks again

    Sean
     
  24. goodhustle

    goodhustle

    New Member

    Joined:
    Jun 4, 2009
    Messages:
    310
    Just finished up my basic GC Plugin integration with achievements. Since I already had a standalone achievement system done in Unity, I just used your library to permit authentication, re-authentication, and syncing to GameCenter accounts, and it seems like it's working well. Nice job, and thanks for the support!
     
  25. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @getluky, Awesome! Glad to hear it's up and running for you!
     
  26. svm5

    svm5

    New Member

    Joined:
    May 14, 2009
    Messages:
    25
    Prime,

    First off awesome plugin. I had already integrated the bluetooth gamekit into a game that got approved today "Croquet!" http://tiny.cc/croquetapp for anyone that wants to check it out. I was able to use your plugin and get gamecenter working in a few days with full networking support, leader boards, and achievements.

    Not sure if anyone else had tried this but I was unable to get the old bluetooth code and the new gamecenter code to work. Basically on pre 4.1 devices I was going to keep showing the bluetooth gamekit stuff. On the iPad when I launch a game it errors out.

    That is not my real question. We decided to just drop support for bluetooth and just do game center. No into my real problem.

    The game works great. I am able to send and receive invites and play a game. The problem occurs when I send a second invite and play a second game. When the game starts the game is running in the background but the screen does not register any touches.

    I am wondering if anyone else has seen something like this? I have been beating my head against a wall for the last two days trying to figure it out. I am wondering if it has to do with the xCode where it is doing

    [[UIApplication sharedApplication] keyWindow]

    Most of my coding over the last two years has been Objective-C so it is most likely that I have a problem with my Unity code but I remember using a statement similar to what you have in grabbing the keyWindow in using an overlay over a movie viewcontroller and experience this same type of issue with the second launch becoming unresponsive to touch.

    Sorry for the rambling but just really hoping someone can shed some light on the situation. Can someone confirm that they have networking working and being able to play multiple matches through multiple request.

    Prime again awesome stuff. One I can figure everything out this is going to go in all our Unity game past and future. :)

    Thanks,
    Steve
     
  27. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @svn, awesome looking stuff! Cant wait to play with Croquet! I have something that you can try and if it works I will put together a real, proper solution. The test will be just to see if it might be what I think it is.

    In the GameCenterManager.mm file, add the following line to line 124 (or somewhere close in the dismissWrappedController method):

    Code (csharp):
    1. _viewControllerWrapper.view.frame = CGRectZero;
    Let me know if that does it for you and if it does I will roll out an official release with an update.
     
  28. svm5

    svm5

    New Member

    Joined:
    May 14, 2009
    Messages:
    25
    prime,

    Thanks for the quick response. I think that fixed the problem. I need to run through some more test but as long as everything looks good we will be submitting the game center update later today.

    I'll keep you posted and let you know when the update gets approved so you can check out what we did with your game center plugin in action.

    Thanks again,
    Steve
     
  29. hxx2010

    hxx2010

    Member

    Joined:
    Aug 31, 2009
    Messages:
    155
    I am not considering upgrading unity 3.0 program, using the old version of unity 2.6 iphone 1.7 pro,
    You can not use plug-ins
     
  30. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @hxx2010, plugins are supported on all versions of Unity 3.0 and also Unity iPhone 1.7 Pro.
     
  31. kenlem

    kenlem

    Member

    Joined:
    Oct 16, 2008
    Messages:
    1,457
    Hi Prime31,

    Any word on the release date for the social plug in?

    Also, have you have any more grand ideas for unique plug ins? (video, audio etc...)
     
  32. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @kenlem, the Get Social Plugin is almost done. It will have Facebook support as well as Twitter using Xauth which means that you can login and post directly to Twitter without having to visit the Twitter website to authenticate.

    After that comes the Etcetera Plugin which currently has on the list:

    - photo (library or taken directly) to texture
    - native loading indicator (with spinner and optional text or image)
    - current language
    - localized strings (for easy localization of all in-game text)
    - email composer
    - web view for opening web pages
    - save screenshot to documents folder
    - UIAlertView access
    - UIAlertView-like prompt for input with 1 or 2 text fields

    That covers my current to-do list.
     
  33. ezone

    ezone

    New Member

    Joined:
    Mar 28, 2008
    Messages:
    327
    Awesome! We'll be grabbing them all!
     
  34. bumba

    bumba

    New Member

    Joined:
    Oct 10, 2008
    Messages:
    358
    does your plugin work with unity iPhone 1.7 Pro ?
     
  35. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @bumba, iPhone 1.7 Pro will work fine as long as you set the .NET API Compatibility to 2.1 (see the bottom paragraph of this page for the details.
     
  36. redd

    redd

    Member

    Joined:
    Jul 23, 2009
    Messages:
    122
    Hi,

    (Hopefully) quick question on Game Center Leaderboards. Does anyone know how to post a elapsed time-type score (HH:MM:SS:MsMs to the Leaderboards? I haven't seen anything in the documentation about that anywhere. Sadly, my question on Apple's board hasn't gotten anywhere, either.

    Thanks,
    - Corey
     
  37. moonjump

    moonjump

    Member

    Joined:
    Apr 15, 2010
    Messages:
    1,643
    When setting up your leaderboard, there are options for what it is a measurement of. Time I seem to remember has 2 options, although I don't know if one allowed for values all the way from hours to fractions of a second.

    And you can set the order for ascending if it is for a lap time you have to beat, or descending for survival times.
     
  38. redd

    redd

    Member

    Joined:
    Jul 23, 2009
    Messages:
    122
    That part I've set up. The question is how to send a time stamp to apple as a score, though. All I can see is that you can only pass in just a integer as a score, which when dealing with time down to milliseconds doesn't make a whole lot of sense.
     
  39. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    I would try just sending something like the following (assuming your formatting is set to elapsed time to the hundredth of a second):

    HH:MM:SS:MsMs

    for .01 seconds send 1
    for .1 seconds send 10
    for 1 second send 100
    for 30 seconds send 3000
    for 1 minute send 6000
    for 1 minute 30 seconds send 6000 + 3000 = 9000
     
  40. redd

    redd

    Member

    Joined:
    Jul 23, 2009
    Messages:
    122
    Thanks, Prime. I'll give that shot and see what happens and let you know how that turns out.
     
  41. redd

    redd

    Member

    Joined:
    Jul 23, 2009
    Messages:
    122
    Okay, have some fun facts to report back on testing.

    Posting '1' gives us
    0:00:00.01
    Okay. Good. Sorta makes sense.

    Posting '123' gives us
    0:00:01.23
    Okay. Still on track. Still making sense. I've got a good feeling about this!

    Posting '123456' gives us
    0:20:34.56
    Annnnnddd my head just slipped a cog. I'm still trying to figure out how 12 turns into 20.

    Prime, if only Apple's docs were as well written as your plugin!

    Anyone out there know how one turns 12 into 20?


    *** Edit ***

    I'll edit myself here and say that I should've re-read your directions above. Turns out you're right. Sending 9456 gives us 0:01:34.56.

    Thanks Prime!
     
  42. impla007

    impla007

    New Member

    Joined:
    Jan 30, 2010
    Messages:
    57
    Because it is hundred of seconds.

    123456 Hundred of seconds give 1234.56 seconds witch are 20minutes and 34 seconds and 56 hundred of seconds
     
  43. moonjump

    moonjump

    Member

    Joined:
    Apr 15, 2010
    Messages:
    1,643
    I've finally got around to working on Game Center after purchasing your plugin a couple of weeks ago.

    I downloaded the latest version and set it up in a new empty project to test it. I am only using the high score and achievement parts for this project, no multiplayer, so I only included the GameCenterTestScene in the test project build.

    I have the test scene working on my iPhone 4. Authenticate worked after a delay. Show Leaderboards displays the empty leaderboard I set up, and Show Achievements displays the achievement I set up. No other buttons appear to do anything, I cannot post scores or anything.

    What should I be seeing?

    Also, Do I just import the plugin again to overwrite the older version in my proper game project?
     
  44. bumba

    bumba

    New Member

    Joined:
    Oct 10, 2008
    Messages:
    358
    How to handle devices which can not use GameCenter(iPod Touch 1G, iPhone 2G)? Lets say i have a button "GameCenter" on the mainmenu. For devices which can not use GameCenter should the button be disabled? Will Apple allow that?
     
  45. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @bumba,
    Don't show the Game Center buttons in your UI when on an unsupported device. There is a method you can call to find out if it's available. I am out of town so you'll have to check the soca for the method name.

    @Moonjump, to play with the test scene a bit more just Load Achievement Metadata before pressing the other buttons and watch the logs.
     
  46. Lostlogic

    Lostlogic

    Member

    Joined:
    Sep 6, 2009
    Messages:
    582
    Any idea why game center available returns false? I bought the plug-in but nothing appears on screen and that check is returning false..
     
  47. Lostlogic

    Lostlogic

    Member

    Joined:
    Sep 6, 2009
    Messages:
    582
    I found the problem...Such a noob. Anyway, it wasn't working on the iPad. Does anyone know when Game Center will work on the iPad? I turned off OpenFeint because the latest beta is not compatible with the latest version of OF. Stuck here with no solution.
     
  48. moonjump

    moonjump

    Member

    Joined:
    Apr 15, 2010
    Messages:
    1,643
    It will be in iOS 4.2 due in November. As an Apple Developer, you can get the beta version now.
     
  49. desmasic

    desmasic

    New Member

    Joined:
    Dec 6, 2007
    Messages:
    82
    Does this plugin also works for Unity 3.0 iOS (not the iOS Pro) ?
     
  50. Hilm

    Hilm

    Member

    Joined:
    Nov 2, 2007
    Messages:
    317
    Hey Prime,
    Great job on the stuff thus far!

    I'm looking to implement push notifications (just simple, push notifications) into an app - is this do-able using a plugin + some PHP backend that we could upload to our own web servers?/ Any plans to produce one?

    Cheers,
    Adam G