Game ideas & features

Your next feature

Leaderboard

Save the score after each round and show who's ahead.

Requires a player session
Godot
Illustration of Leaderboard
Your visible result

Your test score appears in the leaderboard after a round.

View leaderboard standings3:54
Open video separately ↗

Prepare the same project

  1. Choose the same project in the dashboard as in your game configuration.

    Leaderboard →
  2. Create or reuse these test entries in the dashboard form. These are example values, not current project data.

    Key (slug)
    weekly
    Sort Order
    DESC
    Accept scores only from validated runs
    false
  3. Save, reload and verify the entries before running the example. Preserve unrelated definitions.

Build this feature

You can preview the guide. Running it requires an active project key. Prepare project

SDK installed, project configuration imported and player signed in.

Save the GDScript, attach it to a node in the main scene and run it. Check Output.

GDScript
res://scripts/leaderboard.gd
horizOn callSetup
1# Attach this script to a node in your main scene.
2extends Node
3​
4​
5func _ready() -> void:
6 # Setup: initialize, connect and sign in a player.
7 var connected = await Horizon.connect_to_server()
8 if not connected:
9 print("Failed to connect to horizOn server")
10 return
11 if not Horizon.auth.isSignedIn():
12 var signed_in: bool
13 if Horizon.auth.hasCachedAnonymousToken():
14 signed_in = await Horizon.auth.restoreAnonymousSession()
15 else:
16 signed_in = await Horizon.auth.signUpAnonymous("StatisticsPlayer")
17 if not signed_in:
18 return
19​
20 # horizOn: submit a score, read the top list and the own rank.
21 var submitted: bool = await Horizon.leaderboard.submitScore(12500, "weekly")
22 if not submitted:
23 push_warning(Horizon.leaderboard.getLastErrorCode())
24 return
25 var top = await Horizon.leaderboard.getTop(10, false, "weekly")
26 for entry in top:
27 print("#%d %s: %d" % [entry.position, entry.username, entry.score])
28 var rank = await Horizon.leaderboard.getRank("weekly")
29 if rank != null:
30 print("Your rank: ", rank.position)
Open the complete SDK sample ↗

Test your new feature.

Your test score appears in the leaderboard after a round.

Choose the same project in the dashboard as in your game configuration.

Endpoints
  • POST/leaderboard/submit
  • GET/leaderboards/{boardKey}/top
  • GET/leaderboards/{boardKey}/rank
  • GET/leaderboards/{boardKey}/around
All endpoints in the API reference