Game ideas & features

Your next feature

Validated Actions

Have the server validate game actions.

SDK developRequires a player session
Unity
Illustration of Validated Actions
Your visible result

A valid action is accepted and an invalid action is rejected.

Validate game actions3:12
Open video separately ↗

Prepare the same project

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

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

    Key (slug)
    weekly
    Accept scores only from validated runs
    true
    Maximum score
    20000
    Minimum duration (seconds)
    0
    Stage required
    false

    In a test project, save these rules with other limits unset. The fixed quickstart bytes test the request protocol. Score 18250 should pass. Start a new run with 20001 to check rejection. Record actual game inputs in your game.

    Leaderboard →
  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.

This SDK example uses develop. Check whether the required APIs exist in your installed SDK.

Save the C# file, attach it to a GameObject and enter Play. Check Console.

C#
Assets/Scripts/ValidatedActionsDemo.cs
horizOn callSetup
1using UnityEngine;
2using PM.horizOn.Cloud.Core;
3using PM.horizOn.Cloud.Manager;
4​
5// Attach this script to a GameObject in your first scene.
6public class ValidatedActionsDemo : MonoBehaviour
7{
8 async void Start()
9 {
10 // Setup: initialize, connect and sign in a player.
11 HorizonApp.Initialize();
12 await new HorizonServer().Connect();
13 if (!UserManager.Instance.IsSignedIn)
14 {
15 bool authenticated = UserManager.Instance.HasCachedAnonymousToken()
16 ? await UserManager.Instance.RestoreAnonymousSession()
17 : await UserManager.Instance.SignUpAnonymous("StatisticsPlayer");
18 if (!authenticated) return;
19 }
20​
21 byte[] inputLog = System.Text.Encoding.UTF8.GetBytes("quickstart");
22​
23 // horizOn: start a run, record the input, submit the validated
24 // score.
25 // 1. Dashboard: turn on "Validated submissions only" for the board "weekly"
26 var va = ValidatedActionsManager.Instance;
27​
28 // 2. Round start: single-use ticket plus server seed
29 var run = await va.StartRun("weekly");
30 if (run == null) { Debug.Log(va.LastErrorCode); return; } // e.g. RUN_RATE_LIMITED
31 var random = new System.Random(run.seed);
32​
33 // Protocol test input only. Replace it with actual recorded game inputs in your game.
34​
35 // 3. Round end: score plus input log (the SDK sends its SHA-256 hash)
36 var result = await va.SubmitValidated(18250, inputLog);
37 if (result == null)
38 {
39 Debug.Log($"{va.LastErrorCode}, run kept: {va.HasActiveRun}");
40 return;
41 }
42 Debug.Log($"Accepted score={result.score}, rank={result.rank}");
43 }
44}
Open the complete SDK sample ↗

Test your new feature.

A valid action is accepted and an invalid action is rejected.

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

Endpoints
  • POST/validated-actions/runs
  • POST/validated-actions/submit
All endpoints in the API reference
Illustration of Leaderboards
Our suggestion for your next step

Give every round a high score.

Save the score after a round and show who's ahead. Keep using your connection and player session.

Tutorial video

Validated ActionsUnity3:28
Open video separately ↗
Server-owned valuesUnity4:44
Open video separately ↗
Input logUnity5:13
Open video separately ↗