Unity3d Guide about Social Game Features integration. Vol. 1 – Google Play Game Services

In this series of articles I will describe integrating social game features for the following platforms in Unity3D game :

  • Apple iOS (Game Center)
  • Android (Google Play Game Services)
  • Android (Amazon Game Circle)

When it comes to integrating social game features in a Unity3d game the following problems arise:

  • All these services are quite similar but have some different APIs that’s why you have to know the differences if you want to unify all these features to work via single interface. You have to be aware of each platform specifics to make this interface simple and elegant. I will describe problems that I faced and solutions to them.
  • Each platform requires specific assets (images, descriptions). If you are aware of this you can give artist a list of required graphics all at once. Also you will design achievement is a way that it is meaningful and correct for all platforms.

I will explore integration on each platform according to the following plan :

  1. Brief Instructions about creating a game (Developer Console, iTunes Connect)
  2. Required assets and descriptions to create leaderboards and achievements.
  3. Which plugin to use?
  4. What is different from other platforms and what to be aware of?

Google Play Game Services

1. Brief Instructions about creating a game (skip this step if you have already configured Google Play Game Services)

You can find detailed instructions in this Google Developers web site article .

1. Go to your Google Play Developer Console to Game Services Tab and click “Setup Google Play Game Services” button.

2. Choose name and category for your game and click “Continue”.

3. Now when your game is created provide information about your game in the Game Details section. (Fill in all the required fields)

4. Link your Android game (if Android:) ) in Linked Apps section.

5. Create all the required Leaderboards and Achievements in the appropriate sections. (Will not go into details here as the process is quite straightforward and there are lots of instructions on the web)

6. Add test accounts and publish your game.

 

2. Required assets and to create leaderboards and achievements.

2.1 Achievements

To publish your game you need to create at least 5 achievements. This is a checklist of what info you need to provide to create achievement :

  • Name
  • Description
  • Icon (512×512 png or jpg) 
  • Is achievement incremental? If yes, provide number of steps between 2 and 10,000
  • Initial state (Revealed or Hidden) – defines whether the user will see you achievement before earning it, in a few words in it means whether achievement is a surprise or not. (iOS Game Center has the same option too)
  • Points – Each game has a number of 1,000 points to award player, this is the number of points current achievement provides. Achievements that are harder to earn usually grant more points.
  • List order.

2.2 Leaderboards

You do not need a leaderboard to publish your game. To create a leaderboard you must provide the following:

  • Name
  • Score formatting (Numeric, Currency, Time)
  • Icon (512×512 png or jpg) 
  • Ordering (Larger is better or Smaller is better)
  • Score limits (optional)
  • List Order

3. Which plugin to use?

There are lots of plugins on the asset store, some of the most popular:

 

Asset Store:


Open Source:

Google Play Games plugin for Unity – a plugin that worked like a charm for me. Another good thing is The Google Play Games plugin for Unity allows you to access Google Play Games API through Unity’s social interface. Plugin is actively developed and documentation is good. Plugin setup is very simple and is done in a few clicks.

 

4. What is different from other platforms and what to be aware of?

 

4.1 Achievement and Leaderboard Ids are generated randomly when you create them.

Unlike iOS Game Center and Amazon Game Circle where you provide your achievement id as a string in Google Play Game Services its generated randomly. You can use and store the same string id for iOS and Amazon, but it will be different on Google Play Services.

 

4.2 Incremented achievements mechanism

This is the place where I encountered a problem. This is the part of plugin description :

If your achievement is incremental, the Play Games implementation of Social.ReportProgress will try to behave as closely as possible to the expected behavior according to Unity’s social API, but may not be exact. For this reason, we recommend that you do not use Social.ReportProgress for incremental achievements.

Even though it is written that it would behave as close as possible it actually worked totally wrong. You are given an PlayGamesPlatform.IncrementAchievement method which increments your achievement progress by the specified value. Unfortunately, I’ve discovered this fact after my iOS Game Center has already been implemented.

This is the way iOS Game Center reporting achievement works : you calculate the percentage (from 0% to 100% – float value), report it and Game Center accepts those bigger than current and ignores those that are smaller than current. And everything is OK.

And now in Google Play Game services you have build logic the way you must report when achievement is incremented. On iOS you can just save progress locally and report percentage when player goes online and it would be fine. And with these incremental achievements you have to keep in mind that if you make any kind of mistake (report incrementing by mistake) it will add it all up. And that’s painful.

 

4.3 Complexity of process of reseting test user achievements and leaderboard

Imagine you are currently testing how your achievements and leaderboards work. You add a test account, report achievements, fix something and need to reset achievements and leaderboards to start over. In IOS Native Plugin I just call GameCenterManager.resetAchievements() and start testing all over again. That’s it!

 

When I started digging how to do that on Android I didn’t expect it to be that impractical. You have to make this request. This thread helped me out so I had to make an Android application signed with release keystore, authenticate with test account, and make this request from device. It may seem like a trivial task but when you are short of time it is not done in 10 minutes. So be ready for this kind of time-wasting.

 

These are the problems that I faced during development and hope after reading this you will be aware of them. Next time I will write a few warm words about Amazon Game Circle Unity3D plugin and its drawbacks. Stay tuned!

  • Ihor Kostenko

    What about iOs implementation?

  • MBehtemam

    great article . thanks