How I implemented Game Center in Unity

Hello all,

I’ve mentioned that i will be writing some Unity related posts. So this will be the first of them.

While developing my game, I wanted to add some missions to encourage players. I thought about it long, and I decided to achieve this with Game Center achievements and Leaderboards. I googled about it but there were almost nothing. Everyone were talking about prime31’s Game Center plugin. As we are Indie Developers, prime31’s plugin is a little expensive to us. So I figured out an approach that worked for myself.

Photo 12.05.2014 23 33 31.png

First of all, If you want to test game center features of your game, you need an iOS developer account. You have got to make arrangements in iTunes Connect. When you set your App ID’s and created an app in iTunes Connect, that you are ready to begin add some achievements. Set your all achievements in iTunes Connect, and create a leaderboard. Thats all with iTunes connect.

Then I created an empty game object then, I attached an Game Center Controller script to it. This object must be alive while we are playing our game. So I added DontDestroyOnLoad method in Start function. When everything is set on iTunes Connect and our game, rest is really simple.

GameCenter usage examples: http://goo.gl/FkLcJA

GameCenterController script: http://goo.gl/UOJSrJ
(I grabbed this script from Unity’s scripting reference.)

That’s all. Congrulations, you succesfully implemented Game Center leaderboards and achievements for your game!

 
136
Kudos
 
136
Kudos

Now read this

Creating virtualenv on Hostgator Shared Hosting

Hello all, I am using hostgator’s baby plan. It’s python packages are outdated or not satisfactory. Also you can’t add new packages to this python installation. 2-3 months ago I tried to install virtualenv, but not success. Today, i... Continue →