Leaderboard Setup
Leaderboards
Hey gamers! Today we wanted to share the progression of one of our key features: the leaderboard.
The competitive (or just self-improvement) aspect of the game is a major selling point for Exclusion Zone: Reclamation, so of course we needed a way to record your best times. After implementing the in-game timer we could finally move forward with that goal. The first implementation of leaderboards was a meagre proof of concept. The leaderboard would display your best time for the one level we had, a dummy time of about 10,000 seconds (approximately 1,666 hours) and a second dummy time of your time minus one second.
This is of course a fun little reference to The Legend of Zelda’s Running Man, who will always beat your time by one second no matter how fast you go. Obviously, this wasn’t what we wanted for a final product, but it was a good foundation.
The next step was to move the leaderboard to its own screen. Previously, the leaderboard was kind of just chilling in the corner while you ran a level. To do this, we migrated the leaderboards to the menu screen, added a new leaderboard category for collecting all the collectables in a level, and added the ability to reset the leaderboard data if necessary. We even went overboard designing a fancy 10-second abortable reset sequence complete with text updates and decimal rounding of the seconds (it’s very cool even if it was a bit frivolous).
We also brought the banhammer down on TheRunningMan and TheWalkingMan. We wanted real player times only. The new iteration of the leaderboard would display your best time and your previous three times separately for normal completion and 100% completion.
Somewhere along the way I had to take on the monumental task of actually saving best times separately on a level-by-level basis. See, we’re using JSON to save and load our data. JSON is a programming-language-independent text format that’s used for storing information and data in a plain text format. It’s a very simple way to read and write stuff like save-data to an external file. After doing some research, I managed to figure out the proper way to get a JSON file to store an array. Normally Unity’s built-in JSON library only stores singular values, but obviously only storing the best time across all levels (which is how it worked in the initial iteration) is not ideal, nor is making separate variables for all previous times in both categories in all levels. Arrays are a good way to solve that problem; making a variable an array makes a list of that variable type. From there, you basically have multiple pieces of data under the same variable name. The problem was that Unity doesn’t handle converting arrays to JSON very well, requiring some additional code.
Of course, there were some problems (a common occurrence in game development). After wrestling with the code for an hour or two I was getting nullreference errors when I tried to save a new leaderboard time. This meant that the system couldn't find the data. I eventually found the problem: the previous file we had saved didn’t have all the data fields we now had in the updated version of the game, so it was creating null (empty) data for those extra data fields when we loaded it. I dug into the files and smote the traitorous JSON file, and wouldn’t you know it, the issues stopped… or did they?
Turns out, I had forgotten about one of the initializing arrays I had used to debug the earlier issue, and it was right after the data was loaded from the JSON. This meant that all the data was set to zero immediately after it was loaded.
Remember; however hard you think it is to code, it’s ten times harder than that.
Even so, we eventually got our regular and 100% leaderboards working, including the best time for each level, and three previous times.
From here we hope to expand the leaderboard functionality in the future with more previous times, previous time sorting, bug fixes, and additional features such as displaying the powerup used for each best time. Please keep an eye out for these new features in the future!
Get Exclusion Zone: Reclamation
Exclusion Zone: Reclamation
Status | Released |
Author | LunarNorthstar |
Genre | Platformer |
More posts
- Organic Asset CreationApr 18, 2024
- Level DesignMar 26, 2024
- IK SetupMar 22, 2024
- UI Design ProgressMar 17, 2024
- Vertical Slice to Beta Visual ProgressFeb 13, 2024
- Prototype to Vertical Slice Visual ProgressDec 14, 2023
- Prototype 1.1 ReleaseNov 20, 2023
Leave a comment
Log in with itch.io to leave a comment.