App42

For the leaderboard of Hexachains i decided to try “App42”. For moment i am developing the PC version of the game and i wanted a simple free solution to get all the score online. “App42” is free for indie until you become successful, you can check their pricing here

So you can have 1 million API calls / months for free, unless you do something terribly wrong in your program it’s more than enough to start. If you happen to need more i’m pretty it wouldn’t be a problem to pay their fee at that point 🙂

They also offer a lot of other stuff, i will not explain them here, it would be too much anyway, but you should have a look on their website

Finally their documentation is nice and well explain, you can find examples for many different platforms. You can get the package for Unity on this page

Create your app / game

Easiest way is just to create your account and follow the step to create your first Game in their backend, they will guide you just after your account is created. Once your are done you will access the backend. You should see the same menu as the picture on the left.

You can add several games into 1 app but only have 1 leaderboard per game. I needed 2 leaderboard for each of my levels (there is 2 game mode). So for each of my levels and modes i create a game inside the App. Names become a bit confusing : App = your game, games = your levels.

So go in “Business Service Manager” > “Game Service” > “Game” and create as much leaderboard as you need. In my case i call them “level_01_normal”, “level_02_normal”…

Then open “Business Service Manager” > “Game Service” > “Score Board” pick your game and board inside the menu. (it will be empty)

Inside Unity

If you download the package you will get “Constant.cs”, you need to change “apiKey” and “secretKey”. You can find those 2 in your backend : “App Manager” > “Application Keys”. You need to change the “gameName” with the name of one of your leaderboard. You can also modify the username.

You should end up with something like this :

public class Constant 
{
	public string apiKey  ="yourApiKey";					// API key that you have receieved after the success of app creation from AppHQ
	public string secretKey ="yourSecretKey";				// SECRET key that you have receieved after the success of app creation from AppHQ
	public string gameName ="level_01_normal";				// Name of the game which you can create from AppHQ console by clicking 
	// Business Service -> Game Service -> Game -> Add Game
	public string description  = "";			// Enter your description
	public string userName  = "PlayerName";
}

Now open the example scene from the package : “App42_Unity3D_SDK_Sample”

You should see a camera with a missing behavior. Just drag the script “ScoreBoardTest” into it and start the scene. If everything is fine you should see the same interface as the picture, you can now do some test, first you will have to save some score with the button “SaveUserScore”, you can save several and change the value “User Score” inside the inspector. I suggest you keep testing that program with different values and check your backend to see your new data.

Finally you should open the script and check the code, it’s shouldn’t be to hard to understand. Something important is the callback object, every time you call a service you need to give an object that will handle the response. In this example the response is handle by “ScoreBoardResponse”. The file will show you how to get the data out of the server response  (scores, names, date…). If you are not a programmer it might be a little difficult, but all the code you need are in those 2 files and you  just need to copy and paste the parts that you need for your project.

Don’t forget to have a look at the documentation, you can find more examples here.

I hope this can be helpful ! If you want to go further and secure your leaderboards you can check  the ACL option here.