Game ideas & features

Your next feature

Validated Actions

Have the server validate game actions.

SDK developRequires a player session
Unity
Your visible result

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

Video coming later

This step does not have a video yet. The guide and MCP request are ready to use.

Validate game actions

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.

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 await UserManager.Instance.SignUpAnonymous("PlayerName");
14​
15 byte[] inputLog = System.Array.Empty<byte>();
16​
17 // horizOn: start a run, record the input, submit the validated
18 // score.
19 // 1. Dashboard: turn on "Validated submissions only" for the board "weekly"
20 var va = ValidatedActionsManager.Instance;
21​
22 // 2. Round start: single-use ticket plus server seed
23 var run = await va.StartRun("weekly");
24 if (run == null) { Debug.Log(va.LastErrorCode); return; } // e.g. RUN_RATE_LIMITED
25 var random = new System.Random(run.seed);
26​
27 // ... play, record the inputs into inputLog (byte[]) ...
28​
29 // 3. Round end: score plus input log (the SDK sends its SHA-256 hash)
30 var result = await va.SubmitValidated(18250, inputLog);
31 if (result == null)
32 {
33 Debug.Log($"{va.LastErrorCode}, run kept: {va.HasActiveRun}"); // e.g. DURATION_TOO_SHORT
34 }
35 }
36}

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