Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

GameCenter Plugin Live! Leaderboards and Achievements!

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

  1. Darkoo

    Darkoo

    Joined:
    Feb 4, 2013
    Posts:
    96
    Hello,

    Is there some kind of demo/tutorial on how to use the multiplayer plugin on a simple game? I have a small game setup with the unity networkview, RPC's and etc. But dont know exactly how I would translate/integrate this over to gamecenter multiplayer plugin..
     
  2. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @Darkoo, the included demo scene will gets all your devices connected and sending data. The plugin exposes a method to send strings (sendMessageToAllPeers) and a method to send raw data as a byte array (sendRawMessageToAllPeers). It is up to you what data you send.
     
  3. Darkoo

    Darkoo

    Joined:
    Feb 4, 2013
    Posts:
    96
    How do I know who the host is in a multiplayer session and is it possible to change host if original host gets disconnected?
     
  4. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @darkoo, it's a peer-to-peer network so there is no single host.
     
  5. Darkoo

    Darkoo

    Joined:
    Feb 4, 2013
    Posts:
    96
    I would like to have only one of the peers to call a function at Awake(). How would I go about doing that?

    I thought I might be able to use "getAllConnectedPlayerIds()" if it recieves all the players in a specific order on all peers I could make sure only playerIds[0] calls the function? is that possible?? and is there a better solution??
     
  6. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @darkoo, that would be up to you to do. There are many ways to do it. For example have each device message the other with a random number and the lowest one wins. There are much more robust ways as well but that is outside the scope of this question and best researched via generic networking books and tutorials.
     
  7. Darkoo

    Darkoo

    Joined:
    Feb 4, 2013
    Posts:
    96
    I'm getting this error in xCode: "SendMessage: object GameCenterManager not found!" I have read "General Plugin Information" and it sais that it is not necessary to add a gameobject with the manager script to the scene since it gets added automatically in runtime.

    Any other reason for this to be happening?
     
    Last edited: Jul 10, 2013
  8. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    Wdarkoo, that is nothing more than a log. It is not an error. It just indicates you are not listening to any events and has no ill effects.
     
  9. Darkoo

    Darkoo

    Joined:
    Feb 4, 2013
    Posts:
    96
    Sorry, forgott to mention: I was wondering that since the Game Center login screen douse not pop up on entering the app, I'm running the Demo scenes from the game center and the multiplayer plugins, all four scenes added to the build.

    It might just be something wrong on my setup of the development environment of xCode. But don't really know what.

    and also everytime I build checking the "capabilities" tab in xCode I see this: http://postimg.org/image/otzfgob3j/ So I hit the Fix Issues tab and they both get fixed


    FIXED:

    After lots of tries I got the game center slide to appear.. but the I got the message "this game is not recognised by game center" every time I tried to login in to game center sandbox.. again after lots of tries it seems the only way to get it to allways work is by adding the app to itunesconnect.apple.com.

    so now everything works.. On to trying to implement this into my game.. :cool:


    btw, thank you prime31 for all the help awesome plugins!!
     
    Last edited: Jul 12, 2013
  10. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,238
    I have GameCenter set up in an app, and when I build the app to an iPad, it triggers the GameCenter login popup. But after that, when I try to enter GameCenter, I get the GC popup with "Loading..." on the green felt...and it never loads, just says Loading forever. Any suggestion as to what I'm doing wrong?

    EDIT: If I quit the app and go into GameCenter, I can see other games, and it has the Sandbox banner on it. But if I go back into my app, it still gets stuck on "Loading...."
     
    Last edited: Jul 12, 2013
  11. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @gecko, you will need to report that to Apple. There is zero API access to any Game Center view available. They keep every bit of it private and only they can diagnose why it would get stuck. This of course assumes the obvious things like having Internet access and trying again in a few hours hVe been considered.
     
  12. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,238
    Thanks, though I'm not too optimistic about getting help from Apple. Especially since I can launch GC itself without a problem -- and my app appears in the GC list of games. It's only when I try to access GC from within my app that I get stuck on Loading....
     
  13. Darkoo

    Darkoo

    Joined:
    Feb 4, 2013
    Posts:
    96
    @Gecho, pls follor my earlier post had similar problem and got it fixed..
     
  14. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,238
    @Darkoo: do you mean this?
    "it seems the only way to get it to allways work is by adding the app to itunesconnect.apple.com"

    I've done that -- and my app does show up in GameCenter's list of games, but I just can't get into GameCenter from within the app.
     
  15. Darkoo

    Darkoo

    Joined:
    Feb 4, 2013
    Posts:
    96
    @gecho: Yes thats what I mean.

    Delete the game from your device, Log out from Game Center, and rebuild to the device. and try to login from your app. And also before building select the target device and make sure checking Capabilities tab and hit "Fix Issues" button if needed, like here : http://postimg.org/image/otzfgob3j/
     
    Last edited: Jul 12, 2013
  16. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,238
    @Darkoo: That worked--simply starting over fresh on all counts. Thanks so much.
     
  17. Darkoo

    Darkoo

    Joined:
    Feb 4, 2013
    Posts:
    96
    @gecho: You are welcome, Glad to have helped!
     
  18. macdude2

    macdude2

    Joined:
    Sep 22, 2010
    Posts:
    686
    When I tried to load the profile picture for the user, the picture that was displayed was one that said 'sandbox' on it even though I set a different picture as my profile in the game center app. Is this what is supposed to happen? I assume once out of sandbox mode, the profile will display correctly? Also, when I create more users, I am not even getting the ability to add a profile picture. Are other people having this problem as well? I accidentally created a sandbox account with my real ID as the sandbox apple ID, could this be the cause of my problem?\\

    Edit: Apparently ios7 still has its fair share of bugs. Once i created a test user on ios6, the profile picture came back. Apparently though, you can't change your profile from the default sandbox picture.
     
    Last edited: Jul 28, 2013
  19. StevenSauer

    StevenSauer

    Joined:
    Mar 25, 2013
    Posts:
    19
    Hello!
    I've been using a bunch of your tools and until now, everything's gone smoothly.

    I'm attempting to use the showLeaderboardWithTimeScope function
    My first question: is this the function I would use to bring up the generic leaderboard front end that shows the list of leaderboards? I know I can use showLeaderboardWithTimeScopeAndLeaderboard to bring up a specific leaderboard.

    Now my problem is that whenever we hit the button to attempt to activate this function, nothing happens. I have left a pastebin of what our output looks like when calling the function.

    http://pastebin.com/AGCDkvAs
     
  20. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @steven, there is nothing out of the ordinary in that log. The demo scene also has a fully functional example that you may want to use for testing.
     
  21. Darkoo

    Darkoo

    Joined:
    Feb 4, 2013
    Posts:
    96
    Hello again.
    I'm having some trouble figuring out how "showMatchmakerWithMinMaxPlayers( int minPlayers, int maxPlayers )" and "findMatchProgrammaticallyWithMinMaxPlayers( int minPlayers, int maxPlayers )" work independently and if they in some way work together..

    Starting a match with "showMatchmakerWithMinMaxPlayers" with minPlayers set to 4, if one or more players leaves/crashes during a game how can/will they be replaced? If a game is started by 4 friends then they obviously want to keep playing together.
     
  22. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @darkoo, they are two totally different ways to find a match. One has a nice, Apple provided UI and is easy to use and the other requires you to handle everything programmatically.

    If someone leaves a match you can use the programmatic, no-UI method of finding more players then call addPlayersToCurrentMatch to add them.
     
  23. unity-tiger

    unity-tiger

    Joined:
    Dec 10, 2012
    Posts:
    3
    @prime[31]
    I little bit confused to differentiate between players in game center multiplayer. Because I have to decide player 1 , player 2 , player3 and player 4 automatically in my game. But I couldn't find a way to differentiate players. Pls help me.
     
  24. Moonjump

    Moonjump

    Joined:
    Apr 15, 2010
    Posts:
    2,571
    Hi Prime31,

    Is there a minimum iOS version supported by your plugin? I am testing achievements on my latest game. It is working on all my devices except an iPad 1 running 4.3.5. The game worked on this device prior to adding your plugin.

    showCompletionBannerForAchievements() only has an effect on iOS 5+ according to your docs, which suggests the plugin works on older devices.
     
  25. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @moon, we dropped support for iOS 4 a few months back for all of our plugins. Most of them still will work on iOS 4 but as we push out updates we will be breaking compatibility and thus only iOS 5+ are now supported.
     
  26. echoic

    echoic

    Joined:
    Apr 29, 2011
    Posts:
    89
    Hi Prime,

    I've got the Game Center plugin working, but there are two things I'm trying to resolve:
    1) When not logged into Game Center, my application will not display the Game Center login screen when I call authenticate during start up. Curiously, this only happens when testing on iPhone 4, everything works fine on my iPhone 5.
    2) I put a 'show achievements' button in my menu. If the player is not logged into Game Center and they touch this button, a simple message appears stating that the player isn't logged into Game Center. Is there any way I can just show the Game Center login screen instead?

    Thanks!
     
  27. echoic

    echoic

    Joined:
    Apr 29, 2011
    Posts:
    89
    One more concern actually, sorry.. I can't find answers on this stuff.

    The Game Center on my iPhone 5 doesn't seem to be recording completion percentage of an achievement, though I suspect this may be Apple's problem?
     
  28. andrej113

    andrej113

    Joined:
    Oct 25, 2011
    Posts:
    30
    Hi,

    yesterday I upgraded to Unity 4.2 from Unity 3.6 and it looks like the GameCenterBinding.reportScore is not working anymore. Everything else works OK. Could this be because I upgraded unity to 4.2 or is something again with the servers? I also imported the newest version of plugin.

    I am sorry for this king of question, but I don't have time to wait for a couple of days to see if scores show up.

    Thanks for any help on this.
     
  29. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @andrej, how about you provide some information for us to work with. What steps are you following to make the issue not work? What is the full log output of the errors that are occurring?
     
  30. echoic

    echoic

    Joined:
    Apr 29, 2011
    Posts:
    89
    So I found answers to two of my problems, but I still don't know why the GC login screen appears when authenticating at launch on iPhone 5, but not the iPhone 4 (when player isn't logged in).

    Any ideas?
     
  31. andrej113

    andrej113

    Joined:
    Oct 25, 2011
    Posts:
    30
    Hi Prime31,

    I get no errors in the log. I have two leaderboards in the game and I just found out that one is working and the other is not. That is: scores get posted correctly on first leaderboard and on the second are not(no scores show up there). I checked IDs and they are both correct. And I think that this started happening after I upgraded Unity to version 4.2 (before I had version 3.5).

    Could that be a problem with Apple servers or am I missing something?

    Thanks for any help!
     
  32. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @andrej, if you are reporting a score and receiving no error then you will need to open a bug report with Apple. Not much we can do to assist.
     
  33. andrej113

    andrej113

    Joined:
    Oct 25, 2011
    Posts:
    30
    Thanks for the info.

    Did anyone else had this problem (one ledarboard working and the other one not)?

    Should this problem go away, after the game will become published on the portal? I am asking this, because I have to finish the game today and don't have time to open bug report on Apple.

    Thanks,
    Andrej
     
  34. OceanBlue

    OceanBlue

    Joined:
    May 2, 2013
    Posts:
    251
    You have two leader boards? Does the score update both leaderboards, or are they for separate games? Just curious if you're posting to two boards at the same time it might be an issue? (I'm just throwing out ideas, I don't know this for certain)
     
  35. andrej113

    andrej113

    Joined:
    Oct 25, 2011
    Posts:
    30
    I have two leaderboards in one single game. The first leaderboard is just the distance travelled and the second lederboard is distance multiplied with a score multiplier. I update both leaderboards like this:

    GameCenterBinding.reportScore(distance, "xDistance");
    GameCenterBinding.reportScore(score, "xScore");

    And the second one is not working. I also tried to switch the order of sending scores, and xScore still didn't work. I noticed this after I made the upgrade to Unity 4.2.
     
  36. echoic

    echoic

    Joined:
    Apr 29, 2011
    Posts:
    89
    .
     
    Last edited: Aug 22, 2013
  37. andrej113

    andrej113

    Joined:
    Oct 25, 2011
    Posts:
    30
    Hi,

    I'm here to report that both of the leaderboards started working correctly today by themselves. So I guess that this was an issues with Apple servers. Maybe this info will save some time to someone who would have similar problems like me.
     
  38. laserlars

    laserlars

    Joined:
    Nov 17, 2011
    Posts:
    255
    The sandbox servers are crappy, as alot of devs has painfully experienced before you. :)
     
  39. echoic

    echoic

    Joined:
    Apr 29, 2011
    Posts:
    89
    Hi Prime,

    If Xcode is reporting GameCenterAchievement identifier percentComplete = 100, but the actual Game Center UI progress indicator for that achievement is showing a different percentage (incomplete), is there anything I can do, or is this an Apple server thing?

    Thank you!
     
  40. acheron studio

    acheron studio

    Joined:
    Aug 20, 2013
    Posts:
    1
    I'm not sure if this is because I'm using iOS 7, but...

    For some reason I'm not getting the banner to show!

    I've got GameCenterBinding.showCompletionBannerForAchievements( ) in my Start( ) method.

    I use this line to post an achievement:

    GameCenterBinding.reportAchievement( achievementID, 100.0f );

    I successfully get the achievement, because when I open GameCenter it shows it as completed! The banner however doesn't show when I unlock it... any ideas?

    Thanks for the awesome plugin.
     
  41. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
  42. unity-tiger

    unity-tiger

    Joined:
    Dec 10, 2012
    Posts:
    3
    @prime[31]

    The PlayerConnected event is not fire during GameCenter connection with ios 6+. Pls help us that how to recognize player connected or not.
    is it any other method and event available for checking player connected or not.
    Thanks
     
  43. blindgoat

    blindgoat

    Joined:
    Oct 24, 2012
    Posts:
    31
    @Prime[31]

    Thanks for your plugins. We've been using your GC plugin for a year or so now and it's been great.

    Your docs say "it is recommended that you call GameCenterBinding.authenticateLocalPlayer as soon as possible after application launch. No other Game Center methods will work until the user is authenticated." (emphasis added)

    Is this a limitation in how you built your plugin or is this something on Apple's side? Is it possible to check if a user is logged into GameCenter WITHOUT bringing up the annoying GC login popup if they are not logged in?

    In our scenario, we want to display their GC friends if they are logged in. If they aren't logged in we don't want to ask them to log in because it's annoying.
     
    Last edited: Sep 11, 2013
  44. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @blind, that is how GC works. Apple's best practices say to authenticate at app launch, every launch.
     
  45. blindgoat

    blindgoat

    Joined:
    Oct 24, 2012
    Posts:
    31
    @Prime[31]

    Figured. Thanks for the quick response. More like "worst practices" ;)
     
  46. Les-Bird

    Les-Bird

    Joined:
    Apr 22, 2013
    Posts:
    12
    @Prime[31]

    Just downloaded the Prime31 plugin for Game Center yesterday and spent almost 2 days trying to get it to work. The problem I'm seeing is that some of the callbacks are not getting triggered. When I run my app, I see this in the log:

    SendMessage: object GameCenterManager does not have receiver for function playerDidAuthenticate!

    Not sure how to fix this problem. This is not an event but a method that is being called directly from the DLL as far as I can tell.

    I will add that when I run the Prime31 demo scene I do not get that message and everything works fine. Bringing the sample demo code over to my scene does not fix the problem. This leads me to believe that there is something in my scene that is breaking the plugin.

    Anyone else having this problem? And if so, did you fix it? And if so, how?

    Thanks.
     
  47. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @les, that particular log on the console means that you are not subscribed to a single event the plugin fires. If you don't subscribe to the events of course you will not receive the data. How would you receive it? Simply subscribe to the events you are interested in to get the data from them when they fire.
     
  48. Les-Bird

    Les-Bird

    Joined:
    Apr 22, 2013
    Posts:
    12
    Note that the function reporting the error is "playerDidAuthenticate", not "playerAuthenticated". The playerDidAuthenticate is a method in GameCenterManager, not an action event.

    Regardless, even when I subscribe to playerAuthenticated it never gets called because it is called from playerDidAuthenticate.

    Maybe I'm not getting it but just to rule out any mistake on my part I moved the demo scripts verbatim to my scene and still got the playerDidAuthenticate message in the log. So in other words I used the exact scripts from the demo scene, did not fix it.
     
  49. Contract-killer

    Contract-killer

    Joined:
    Sep 21, 2012
    Posts:
    42
    Hi , I am facing trouble in making the gamecenter integration. I am not able to connect head and tail of the api. Can you help me , by giving me any video example. I am not able to find when and where I will call these functions. Even my app getting crashed when I am calling this function GameCenterMultiplayerBinding.showMatchmakerWithMinMaxPlayers(1, 1);
     
    Last edited: Sep 18, 2013
  50. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @contract, there is no video tutorial available. The plugin comes with a demo scene that you can launch on 2 or more devices. You can then watch the logs and the demo scene will print out each event as it happens. That is the quickest and easiest way to learn how the plugin works.