Note: You are viewing the Unreal version of this topic. To view this topic for Unity development, see Leaderboards (Unity). To view this topic for native development, see Leaderboards (Native).
Leaderboards provide a way for a game to keep track of players and their scores in relation to other. Leaderboards can help create competition and increase engagement among your users.
For example, in a racing game, for a specific track you might have a leaderboard for the fastest lap time, sorted by lowest time, and a leaderboard for the most number of wins, sorted by the largest value. A game may have many different leaderboards.
The Oculus Platform manages the leaderboard data, however, you will be responsible for displaying, reporting, and verifying the leaderboard data in your app.
To manage leaderboards, Oculus offers:
See the Implement section for steps to add a leaderboards to your apps.
Note that this feature accesses user data and may require you to complete the Data Use Checkup form prior to submitting your app to the Oculus Store. For more information, see Complete a Data Use Checkup.
You can optionally choose to make leaderboards user-facing, meaning a user can see their rank compared to friends and other users in the Oculus app. You can also choose to have notifications automatically generated when a user passes a friend’s leaderboard score.
The following image shows a user-facing leaderboard.
The first step in adding leaderboards to your game is defining them in the developer dashboard. Navigate to Platform Servies > Leaderboards in the Developer Dashboard and select the app that you would like to create a leaderboard for.
Select Create Leaderboard and enter the following information:
Select Submit when finished to save the leaderboard.
You can update leaderboard settings at any time in the Developer Dashboard. You may also clear the results in a leaderboard and reset the scores.
To help increase engagement with your leaderboards, follow these best practices:
You can edit any of a leaderboard’s properties except its API Name. This means you can add translations and social feature after you have created it. To edit a leaderboard:
The following image shows an example of the Edit Leaderboard page.
Once you’ve finished creating the leaderboards in the dashboard, you can begin to integrate them in your game or app. When you call the functions in this section use the Leaderboard API Name you defined in the developer dashboard.
A leaderboard contains an array of leaderboard entries, and a leaderboard entry represents one users score and rank in a particular leaderboard.
For Unreal development, you can use the Platform native API and information found in the Platform Unreal Development - Get Setup guide.
Details about each function that follows can be found in the Leaderboard Requests Reference .
This method retrieves an array of leaderboard entries for a specified leaderboard.
ovr_Leaderboard_GetEntries()
If no error occurred, the result will contain an array of leaderboard entries.
This method retrieves a list of entries starting after a rank that you define. For example, if you specify a list with an ‘afterRank’ of 10, you’ll get a list starting with the 11th position.
ovr_Leaderboard_GetEntriesAfterRank()
If no error occurred, the result will contain an array of leaderboard entries after the rank you specify.
This method retrieves the next group of leaderboard entries. This can be used to paginate the leaderboard data.
ovr_Leaderboard_GetNextEntries()
If no error occurred, the message will contain an array of leaderboard entries.
This method retrieves the previous group of leaderboard entries. This can be used to paginate the leaderboard data.
ovr_Leaderboard_GetPreviousEntries()
If no error occurred, the result will contain an array of leaderboard entries.
This method will write a new leaderboard entry to a specified leaderboard for the current user. It is not an incremental update, it will overwrite the existing entry.
ovr_Leaderboard_WriteEntry()
If no error occurred, the result will contain a leaderboard status.
Use this method to get the total number of entries in the leaderboard so that you can show a users rank within the total number of entries. For example, use this method to display that a user is number 50 out of 200 entries.
ovr_LeaderboardEntryArray_GetTotalCount()
Returns an unsigned long that specifies the total count of leaderboard entries.
Request a block of leaderboard entries for the specified user ID(s) for viewing by this client. Use this method to get rankings for users that are competing against each other. You specify the leaderboard name and whether to start at the top, or for the results to center on the (client) user. Note that if you specify the results to center on the client user, their leaderboard entry will be included in the returned array, regardless of whether their ID is explicitly specified in the list of IDs.
ovr_Leaderboard_GetEntriesByIds()
If no error occurred, the result will contain an array of leaderboard entries.
To implement leaderboards, there are two different processes.
Retrieve and Display Leaderboards - Display the current leaderboard state before a game begins.
For Unreal, you can use OSS nodes in your game blueprint. Add the Read Leaderboard Integer node. You will need to input:
The blueprint will return whether it was successful, and the leaderboard value if it was successful.
Update Leaderboard Entries - Write the results of the current game to your leaderboard. A user may only have one entry on each leaderboard, subsequent entries will overwrite the existing entry on the specified leaderboard.
For Unreal, with OSS nodes in your game blueprint, add the Write Leaderboard Integer node and set the following inputs:
The blueprint returns whether it was successful in writing the value.
When implementing leaderboards, there are two common scenarios you should be aware of. They are:
LeaderboardStartAt
enum to define where the values returned start or are centered. To retrieve only the current user, center on the viewer and limit results returned to 1.LeaderboardFilterType
enum to define the results returned.You may need to manipulate a leaderboard from your trusted server. For details on leaderboard server-to-server APIs, see Leaderboard Server to Server APIs.