Posted May 06, 2025 by Shivani
To track competitive progress and display the top players, I implemented a Leaderboard System using PlayFab's player statistics API. This system allows players to see how they rank against others based on the number of wins they've achieved.
Ranking Menu UI
First, I needed to set up a leaderboard in PlayFab under "Leaderboards (Legacy)". I named this leaderboard "AmountOfWins" and made sure it reset manually, and the highest value is shown first.
PlayFab Statistics Properties
After a match is won, the game sends the player's win count to the PlayFab server:
PlayfabLeaderboard.cs
All leaderboard information shown in PlayFab
Each user will be ranked and will be able to see their display name and the number of wins they have.
The leaderboard is requested when the player clicks on the "Ranking" button to view rankings:
Leaderboard.cs
The returned leaderboard data is then shown in the ranking menu UI using a prefab for each player:
Leaderboard.cs
Final Version:
This project has been a major learning experience, giving me a deeper understanding of how multiplayer games work. I learned how to sync player data using Photon PUN and how to securely store and manage player data in the backend with PlayFab. Throughout development, I consistently learned from my teammates, which helped me grow both technically and creatively.
Building a game in this genre has been one of the most unique and rewarding projects I've worked on. I enjoyed the entire development process as it constantly pushed me to learn something new at every stage.
[1] YouTube, Jared Brandjes. Playfab + Unity - Statistics, Leaderboards & Display Name. Available at:https://youtu.be/99nxGhk4RNI?si=N662QAcc4_MFZCx8.
[2] YouTube, Coco Code. Easy and free online leaderboard in Unity! - PlayFab in Unity tutorial (#2). Available at: https://youtu.be/e2RXDso6fWU?si=Ymbk3lO7oLgnp4Hb.