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 create a game by selecting “+add game”.
ScreenHunter_132 Jan. 11 17.04
– at 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


Project Y

[ Project Y ] Bullet hell bullets system version 0.4

First things first, I decided to keep it a 2D game but started all over from scratch and building it up again. At the moment I have a working bullet system which I mostly have been polishing the last week. The result is that I can have around 2000 bullets on my screen before my frames per second (fps) drops to below 50-60. This is a huge improvement of the first version which only could hold about 400. Here is the version 0.3 which is only slight less efficient:

What I basically started out with was a simple system:
– a spawn script with bullet pattern coroutines in it which places an x amount of bullets over an y amount of time in a z degrees of rotation.
– a bullet script with constant forward movement attached to the bullet prefabs
– a simple object pool that pools the bullets that are not needed and where I can request new bullets.

This then evolved into a system where the bullet behavior are all regulated by 1 manager that does 1 update for all the bullets on the screen. Because having 1000 bullets on the screen all with their own update results in a extra 1000 updates which is not very efficient. After removing the script from the bullet prefab I immediately saw a performance boost, which was expected.

The last thing I did was giving the 2d prefabs their rigidbody back. Yes putting them back, I  initially removed the rigid bodies because I thought that would make it more efficient. But this is not true it seems. Thanks to Luuk pointing it out, it seems when you move an object with a collider and without a rigidbody, the complete static collision data needs to be recalculated, which is slow. So: what you should do, is to make sure that all objects you intend to move have attached rigidbodies,  if you don’t want the objects to be moved by the physics engine as me, then just set isKinematic on true. For best results, just use Rigidbody.MovePosition(). Which I did and BAM bullets on screen ++!