In this tutorial, I’ll be going over how to create a leaderboard for Android games in Unreal Engine 4.
The process of creating a leaderboard is effectively the same as creating achievements, but simpler. Mostly because you probably won’t have more than one, making the arrays unnecessary.
There’s also no need to store variables for things like the value needed to unlock anything, or the percent of progress you’ve made toward completion.
First you will create the actual leaderboard through a combination of your Android Developer Console and the UE4 project settings, which as I’ve said is basically identical to the process for creating an achievement. Except of course that you will be going through the “Leaderboard” tabs in the developer console and project settings instead of “Achievements”.
Inside your blueprint, it’s just a simple matter of placing a “Write Leaderboard Integer” node, then connecting a “Get Player Controller” node, typing the name of your leaderboard into “Stat Name”, and plugging the variable you want to add to your leaderboard into “Stat Value”.
After that, most of it is handled by Google Play automatically. The leaderboard will only store one value for the player. If the new value is smaller than the one already stored for that player, then it will simply do nothing. If the value is higher than the one already stored for that player, then the new value will replace the old one on the leaderboard.
If you want to display the leaderboard to the player, simply use a “Show Platform Specific Leaderboard Screen” node, and type the name of the leaderboard you want to display into “Category name”.