Project Y

[ProjectY] Using the GameJolt API in Unity3D

Been a while since my last post, for my latest project I have been playing around with the GameJolt API. For those who don’t know GameJolt, it’s basically a platform like steam but then for indies. Currently GameJolt has been confirmed to run properly on PC and Mac builds, and also Webplayer and WebGL builds (source). GameJolt is a very easy way to incorperate a login and leaderboard system into your project. All you have to do is:

– in unity: import the GameJolt API package (download).
– in unity: add the GameJoltAPI prefab in your game scene.
– in unity: go to Edit -> Project settings -> Game Jolt API. You will need to set things here after you create your game at GameJolt (see next 2 steps)
– at GameJolt.com: create a game by selecting “+add game”.
ScreenHunter_132 Jan. 11 17.04
– at GameJolt.com: take note of a few things that you’ll need later to do requests and which are to be used in the settings: First you need to get the Game ID and Private Key which you have to fill in the settings which has been highlighted 2 steps back. You can find these at your API settings under the Game API tab (see image below). To get there you’ll have to go to your dashboard and select your game.
Then there is your “Game Token” and your “TableId”, you will need these to add scores and get your leaderboard. Your game token can be found at you user tab (see image above). To get the tableID you’ll have to go to your dashboard, select your game and go to the GameAPI tab where you’ll find the TableId under the scores selection.
ScreenHunter_135 Jan. 11 17.14

ScreenHunter_133 Jan. 11 17.04

For the standard login you can call: GameJolt.UI.Manager.Instance.ShowSignIn();
After that you can use  GameJolt.UI.Manager.Instance.ShowLeaderboards(); to show the overal leaderboard of your game. However if you want to get user specific data you’ll have to create a custom view and use GameJolt.API.Scores.Get(); to get data.

Example User specific highscore get:
GameJolt.API.Scores.Get(LeaderboardResult, _tableID, 5, true);

private void LeaderboardResult(GameJolt.API.Objects.Score[] scores)
{
for (int i = 0; i < scores.Length; i++)
{
Debug.Log(scores[i].PlayerName + ” – ” + scores[i].Value);
//do stuff with the scores here
}
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>