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

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @desmasic, the plugins are true plugins and are supported in all versions of Unity 3 (Basic and Pro) and Unity 1.7 Pro. The only version of Unity that does not support true plugins is Unity 1.7 Basic.

    @Hilm, you don't need a plugin to implement push notifications. All you need is a server and the WWW class.
     
  2. Hilm

    Hilm

    Joined:
    Nov 2, 2007
    Posts:
    338
    And the know-how... Which I unfortunately don't have, but would be willing to pay for :p?
     
  3. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @Hilm, I currently have no plans to release any server side code but if there is enough demand I would most definitely consider making server side packages with some associated Unity code for easy access to certain features.
     
  4. Hilm

    Hilm

    Joined:
    Nov 2, 2007
    Posts:
    338
    How much would you charge for writing them as a custom job - on the basis I'm happy you selling it as a package afterwards?
     
  5. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @Hilm, this is a conversation best had offline rather than fill the forum up with our chatting. Feel free to shoot me an email and we can chat more. The cost would vary considerably based on usefulness to others, programming language/s and their popularity, extensiveness of integration, etc. Send me over as much detail as possible and I can let you know.
     
  6. eviltenchi_84

    eviltenchi_84

    Joined:
    Feb 18, 2010
    Posts:
    99
  7. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @eviltenchi_84, those are local notifications which differ greatly from push notifications.
     
  8. JamesMobot

    JamesMobot

    Joined:
    Jul 8, 2010
    Posts:
    170
    May be a silly question but I have been using the plugin for about 3 or 4 weeks
    Everything has been working fine.

    One thing though, I have not tested my authentication screen since before unity supported 4.1 (a couple weeks)

    Tonight i logged out and made a build of my game. It authenticated me but, it did not open up the game center stuff automatically.

    The GC options do open from my buttons but, If i recall, the initial GC windows would open when you first authenticate? Has that changed?
     
  9. jackshiels

    jackshiels

    Joined:
    Feb 29, 2008
    Posts:
    357
    Hi there,

    Forgive me if this has been asked before, but will you be supporting the iOS 4.2 beta any time soon? We want a game out with support for this when the 4.2 update launches and will purchase if the support is there.

    Jack
     
  10. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @RobotsVsWizard, 4.1 shows the logged in message notification for me. You shouldn't see anything else other than the small banner that slides in from the top of the screen.

    @jackshiels, as long as you are using the newest version of the Plugin it will autodetect that latest SDK that you have installed and use that to link against so as soon as 4.2 final is released and installed on your system it will link against it or if you installed 4.2 beta in the /Developer directory on your computer.
     
  11. stuartjeff

    stuartjeff

    Joined:
    May 28, 2009
    Posts:
    9
    I purchased your Game Center plugin recently and overall I have been very impressed. I was able to get leaderboards, achievements, and basic matchmaking working in a few hours. The one thing I am having a hard time with though is invites. I am using the standard gui to send the invites and I am receiving/accepting them just fine but the invite never appears to be handled by the invitee. According to apple the game center ui should be shown by your app immediately upon the acceptance of the invite. It looks like you are setting up the handler and showing the correct view controller in GameCenterMultiplayer.mm but I'm never hitting that code. Any thoughts on what could be going wrong?

    I have your GameCenter and GameCenterMultiplayer prefabs in my scene.
    I wrote my own listeners and have them on persistent object (I'm getting calls from both GameCenter and GameCenterMultiplayer as well)
    I am authenticating the local player.

    Everything else seems to work but invites don't do anything.

    Any help would be greatly appreciated!


    UPDATE: It turned out that my listener was persistent but the calbacks were registered in the Start method while they were unregistered in the OnDisable method. This meant that if I switched scenes then all of my callbacks would become unregistered and never be reregistered.
     
    Last edited: Oct 6, 2010
  12. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @stuartjeff, are you authenticating the local player as soon as possible after launching your game? It should be the absolute first thing you do after launch. Are you being sure to have both of your devices fully logged out of the Apple GameCenter application and are you using an Xcode debug build?
     
  13. JamesMobot

    JamesMobot

    Joined:
    Jul 8, 2010
    Posts:
    170
    Yes, I do get the welcome back if i am logged in. However upon the initial login there is nothing.
    I played some other games and they are the same. I guess that is just the way it works.

    Maybe i just got used to open feint where it directs you to the OF main page after you log in.

    Anyways it's working great. The leaderbaords and all the achievements are working perfectly. Again nice job!

    So much better than the official plugin that Open feint made for Unity. They should hire you to make one for them!

    My other question is iads related so ill head over to your other forum posting :)
     
  14. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    you didn't create a bundle identifier for this purpose. gamecenter is a identifier based functionality (like inapp store, iad etc)
     
  15. hxx2010

    hxx2010

    Joined:
    Aug 31, 2009
    Posts:
    155
    I use your gmaecenter example, found a problem
    When invited to friends after the game the player has been at the center waiting,
    I have two ipod, the other received an invitation, directly into the game interface, but did not enter the center of the interface to the game
     
  16. hxx2010

    hxx2010

    Joined:
    Aug 31, 2009
    Posts:
    155
    This problem has been solved
    Be sure to click "send to all" button

    But also has a problem, so I was wondering
    Game center multiplayer game, when in the battle to pass each other information, is not to use your plug-gamekit

    Hope to use the game center and a simple example of the fighting, it was easy to use plug-in
     
  17. bumba

    bumba

    Joined:
    Oct 10, 2008
    Posts:
    358
    i dont find the method. Can you help me out?

    Another question:

    Can i build my game with BASE SDK: 4.1 but build the game for 3.2.1 ? And use Game Center?
     
  18. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @bumba, check the first method in the docs. You can most certainly use Base SDK 4.1 and any deployment target you want. The plugin weak links the required frameworks and checks for their existence before using them.
     
  19. hxx2010

    hxx2010

    Joined:
    Aug 31, 2009
    Posts:
    155
    I strongly protest against your prime31
    I purchased all your plug-technetium
    Any answer you do not
     
    Last edited: Oct 4, 2010
  20. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @hxx2010, I think judging by the 9 pages of replies on here that questions not only get answered, but they are answered in a timely manner. Feel free to state your questions or if you prefer send a support email via the website.
     
  21. bumba

    bumba

    Joined:
    Oct 10, 2008
    Posts:
    358
    1)do i really need to add a new application on iTunes Connect to test Game Center? Because my screenshots and description is not finished yet

    2) how could i beta test game center with other people? is this possible?
     
  22. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @bumba, you absolutely need either a new game in ITC or add GameCenter to an existing game. You don't need screenshots or a description to add a game to ITC. You can use ad hoc builds for beta tests as well.
     
  23. bumba

    bumba

    Joined:
    Oct 10, 2008
    Posts:
    358
    but if i want to test my own leaderboards i need to add them on iTunes Connect?

    I have some troubles with the plugin. Im using unity iPhone 1.7 Pro.

    I made a simple test scene with your GameCenterGUIManager script.

    I setted iPhone SDK Version to Unknown

    On Xcode i setted Base SDK to 4.1 and build in debug mode for 3.2.1

    But now i get 6990 errors after building :-(
     
  24. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @bumba, the ONLY way to have a leaderboard is to put it in ITC. Double check your setting being sure that for both debug an release builds you have set the Base SDK properly and the Deployment Target.
     
  25. eviltenchi_84

    eviltenchi_84

    Joined:
    Feb 18, 2010
    Posts:
    99
    Also, make sure you have the appropriate frameworks in your XCode project. I had to add the CoreGraphics, AVFoundation and Gamekit frameworks before mine compiled...although this was only the case with Unity 3, as Unity 1.7 did not seem to need this step.
     
  26. bumba

    bumba

    Joined:
    Oct 10, 2008
    Posts:
    358
    ok thx its working now but if i click Post Score nothing happen. If i click show leaderboards i can see my created leaderboards but without score.


    For the beta testers: do they have to use the sandbox too?
     
  27. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @bumba, the ad hoc build might force beta users to be in the sandbox but don't quote me on that. Give it a quick test before sending it to your betas. Be sure you are listening to the relevant events when posting a score so that you will know what the error is. Also, watch the Xcode logs for hints (tutorial in the top paragraph of the docs).
     
  28. bumba

    bumba

    Joined:
    Oct 10, 2008
    Posts:
    358
    ok i will test it, only must tell them that they must create a sandbox account

    ... Another question: I have several scenes in my game. Should i only authenticate the player in the mainmenu? and save it in playerprefs? Or should i authenticate the player in every scene? Because maybe he starts later in another scene and not the mainmenu.
     
  29. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @bumba, authenticating in just the first scene the user reaches is all you need to do.
     
  30. bumba

    bumba

    Joined:
    Oct 10, 2008
    Posts:
    358
    but if i post a score with GameCenterBinding.reportScore( 125, "1" ); in different scenes i should make something like:

    if(isPlayerAuthenticated()){
    GameCenterBinding.reportScore( 125, "1" );
    }

    right?
     
  31. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @bumba, correct. You don't want to try to report a score when you don't have an authenticated player.
     
  32. bumba

    bumba

    Joined:
    Oct 10, 2008
    Posts:
    358
    thanks man you are great!

    last question i hope ;-)

    why do i have to press GameCenterBinding.loadLeaderboardCategoryTitles(); and only after pressing that i can post a score in your example scene. Do i have to call it everytime before i post a score?
     
  33. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @bumba, the example scene doesn't have anything hardcoded at all. Without loading the category titles it doesn't have a categoryId to post the score to. You only need to call it once because it stores the info locally in the example.
     
  34. bumba

    bumba

    Joined:
    Oct 10, 2008
    Posts:
    358
    1)in my game when i post only GameCenterBinding.reportScore( 25, "2" ); the score will not be posted?

    2) Is there a method to show the general leaderboard menu (the menu which list the leaderboard names)
     
  35. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @bumba,

    1) if your leaderboards categoryId is "2" than that should work for posting a score as long as the player is authenticated and has access to the leaderboard.

    2) from the docs:

    Code (csharp):
    1. // Shows the standard GameCenter leaderboard with the given time scope.
    2. public static void showLeaderboardWithTimeScope( GameCenterLeaderboardTimeScope timeScope )
     
  36. bumba

    bumba

    Joined:
    Oct 10, 2008
    Posts:
    358
    must i add the delegate in my code?

    private List<GameCenterLeaderboard> leaderboards;
    GameCenterManager.categoriesLoaded += delegate( List<GameCenterLeaderboard> leaderboards )
    {
    this.leaderboards = leaderboards;
    };


    Im using javascript and i have no idea how to change the code
     
  37. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @bumba, retrieving the list of GameCenterLeaderboards isn't required but if you want to you can use the code below (untested and there are probably other ways to do it in Javascript but I avoid Javascript due to it not having all the features and support that C# does):

    Code (csharp):
    1. void Start()
    2. {
    3.         // add the event listener
    4.     GameCenterManager.categoriesLoaded += categoriesLoaded;
    5. }
    6.  
    7.  
    8. void categoriesLoaded( leaderboards )
    9. {
    10.        // remove the event listener
    11.        GameCenterManager.categoriesLoaded -= categoriesLoaded;
    12. }
     
  38. bumba

    bumba

    Joined:
    Oct 10, 2008
    Posts:
    358
    thanks it working....

    i have an automated overall category, what exactly does it do? Sum up all categories?
     
  39. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @bumba, I'm not sure what you mean by "automated overall category".
     
  40. azeitler

    azeitler

    Joined:
    May 14, 2008
    Posts:
    162
    Hi there!

    This sounds really great. I was about to tackle GameCenter on my own, but now I am really thinking about getting your plugin.
    I've gone over the documentation real quick, and one think immediately bothered me: you use generics. For me this always is a bit of a no-go, as there is no full support of Generics in the monotouch profile (which you will be dependant on when trying to use the .Net 2.0 Subset to reduce build size).
    This is the only thing keeping me from purchasing this plugin.

    - Andreas
     
  41. maglat

    maglat

    Joined:
    Jul 9, 2010
    Posts:
    111
    I cant figur out how I can set up a game in Itunes connect without screenshots or description :(

    EDIT: I managed it! :)
     
    Last edited: Oct 6, 2010
  42. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @azeitler, generics are a fabulous language feature that are not only more performant than standard collections (no need to box/unbox or cast) but they also make code more readable. If the generics are really that big of an issue for you there is nothing stopping you from just changing the very few occurrences to ArrayList or some other collection class.
     
  43. bumba

    bumba

    Joined:
    Oct 10, 2008
    Posts:
    358
    some beta testers have problems with login in with game center. If they want to log in the game crashed. But it doesnt happen for everyone
     
  44. Jacob-Williams

    Jacob-Williams

    Joined:
    Jan 30, 2009
    Posts:
    267
    @Prime31 - I have tested this plugin extensively over the last couple of days, and have a few questions for you.

    First, there seems to be a bit of a bug when inviting a friend that does not currently have the game running. For instance, if I start the game on one device, and send a notification to another, when the second device finishes loading the game, the match maker is never shown and the second device never connects to the game session. However, if I start the game on both devices and then send the request, everything works as expected.

    Second, I can't seem to get Voice Chat working correctly, but I have made a few assumptions on how it works, and that may be causing the problem. Each game that is started has a unique ID, and on a button click, I enable voice chat and create a channel named by that id. There are a couple of things that I do here that may be causing some issue. Here is my code:

    Code (csharp):
    1. GameCenterMultiplayerBinding.enableVoiceChat( true );
    2. GameCenterMultiplayerBinding.addAndStartVoiceChatChannel( gameId );
    3. GameCenterMultiplayerBinding.receiveUpdates( gameId", true );
    As you can see, everything is done in the same frame and this code is the same on every client, so each client can be the one that creates the channel if need be. I assume that if a channel already exists, it will just skip that line and connect to the channel, but this is where I may be going wrong. Any advice would be greatly appreciated.
     
  45. dock

    dock

    Joined:
    Jan 2, 2008
    Posts:
    603
    Prime31 - do you have a demo app on the app store to demonstrate your implementation of these features? I'm especially interested in the Game Center and social plugins, but I would prefer to see some robust demonstrations of the process.

    Also, previous plugins (such as iPhone Enhancement Pack) became useless because they would break frequently with new iOS updates. Is there anything in your plugins to prevent this problem? Last time I ended up having to rip out plugins and remove functionality from my game.
     
  46. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @Jacob, for the first issue, are you calling authenticateLocalPlayer as the first thing you do when launching your game? Also, this may sound odd but try calling GameCenterMultiplayerBinding.isVOIPAllowed() right when you call authenticateLocalPlayer. The reason is to get the MultiplayerManager booted up and listening for invites. I may need to add a new method to initialize the invite listener if that works for you. You can check the Xcode logs and you should see a log that starts with: "received invite from..."

    You should be fine adding and starting voice chat channels on multiple devices at the same time. GC should be able to handle that for you. What are you seeing in the logs when you start up the chat?
     
  47. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @dock, there is no demo app available in the App Store right now. All time has been spent getting all the requested plugins out. There are some apps out already from other folks that you can check out though. Anyone with a released app feel free to chime in here. Off the top of my head there is Viking Funeral (GameKit multiplayer) and Tater's Training Trash Yard (GameCenter plus an awesome looking Unity book coming in a couple weeks).

    There are a few safeguards built in to the plugins to let them keep themselves up to date. For example, all plugins will automatically link against the latest version of iOS that you have installed in your Developer folder. So as new iOS version come up they get linked up automatically. Another nice thing about them is they are modular: each plugin solves a specific problem using a specific API. This makes keeping update releases a lot easier for me which means you guys get them faster.
     
  48. maglat

    maglat

    Joined:
    Jul 9, 2010
    Posts:
    111
    I finally managed to post achievements + score to my gamecenter app :) It was very easy to get it running!
    But I still have a question!
    In most of the games with gamecenter support when you get a achievement, a short dialog from the top with the message + picture of the achievement pops up.
    When I activate a achievement in my game, nothing visual happens, but the achievement is posted when I check the GC. It works but is not nice.

    Are this messages selfmade or is this a function from the GC itself. Is it possible that you integrate this?
     
  49. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @maglat, the notifications are all self made. They are not a part of GC. I could certainly implement something like that but it is probably best left to be done in Unity. This will keep the game running smoothly and let you make the notifications fit the style of your game. I would recommend just making a little script and GameObject that you can spawn when an achievement is reached then destroy it a few seconds later.
     
  50. Jacob-Williams

    Jacob-Williams

    Joined:
    Jan 30, 2009
    Posts:
    267
    @Prime31 - Calling GameCenterMultiplayerBinding.isVOIPAllowed() (and authenticating the user when the app starts) didn't fix the issue. The problem here is that it is hard to troubleshoot. When the app is running (so I have access to the xCode Console) the invites are received and handled perfectly. It is only a problem when the game is not already running and an invite has been accepted.

    Also, Still no luck with Voice Chat. When enabled, it doesn't show anything in the xCode log. When disabled, I get the following error:
    Code (csharp):
    1. error setting category override to speaker: 2003329396
    All the listener prefabs are in the scene - what am I missing?