Search documentation

Find pages, sections, and content across all docs.

WavedashDocs

Achievements & stats

Track player statistics and unlock achievements

Stats are numbers that track progress per player — total kills, distance run, games played. Achievements are milestones players unlock, like "First Blood" or "Centurion." You define both in the Developer Portal and interact with them from your game through the SDK.

Setting up achievements

Go to Developer Portal → your game → Achievements to create and manage achievements. You can add them one at a time or bulk import via JSON.

Each achievement has:

FieldRequiredDescription
IDYesA unique identifier like FIRST_BLOOD
TitleYesThe display name players see, like "First Blood"
DescriptionYesWhat the player did to earn it
ImageNoA custom icon shown in the achievement list
Trigger ruleNoAutomatically unlock when a stat reaches a threshold

Achievements can be unlocked in two ways:

  1. Manually — your game calls the SDK to unlock it
  2. Automatically — you set a trigger rule (e.g. "Total Kills is at least 100") and Wavedash unlocks it when the stat threshold is reached

Bulk import

Click Add achievement → Import JSON to import multiple achievements and stats at once. The expected format:

{
  "achievements": [
    {
      "identifier": "FIRST_KILL",
      "display_name": "First Blood",
      "description": "Get your first kill",
      "stat_requirement": null
    },
    {
      "identifier": "GOLD_100K",
      "display_name": "Rich!",
      "description": "Collect 100,000 gold",
      "stat_requirement": {
        "stat": "GOLD_COLLECTED",
        "threshold": 100000
      }
    }
  ],
  "stats": [
    {
      "identifier": "GOLD_COLLECTED",
      "display_name": "Gold Collected"
    }
  ]
}

Existing items (matched by identifier) are skipped.

Setting up stats

Go to Developer Portal → your game → In-Game Stats to define stats. Each stat has an ID and a display name. Stats persist across sessions as numeric values (Godot and Unity expose both int and float variants; JavaScript stores them as plain numbers).

Working with stats

func _ready():
    WavedashSDK.current_stats_received.connect(_on_got_stats)

func load_stats():
    WavedashSDK.request_stats()

func _on_got_stats(response):
    if response.get("success", false):
        var kills = WavedashSDK.get_stat_int("total_kills")
        print("total_kills: ", kills)

func add_kill():
    var kills = WavedashSDK.get_stat_int("total_kills") + 1
    WavedashSDK.set_stat_int("total_kills", kills, true)
async void Start()
{
    bool ok = await Wavedash.SDK.RequestStats();
    if (ok)
    {
        int kills = Wavedash.SDK.GetStatInt("total_kills");
        Debug.Log($"total_kills: {kills}");
    }
}

public void AddKill()
{
    int kills = Wavedash.SDK.GetStatInt("total_kills") + 1;
    Wavedash.SDK.SetStatInt("total_kills", kills, storeNow: true);
}
const response = await Wavedash.requestStats();
if (response.success) {
  const kills = Wavedash.getStat("total_kills");
  console.log(`total_kills: ${kills}`);
}

function addKill() {
  const kills = Wavedash.getStat("total_kills") + 1;
  Wavedash.setStat("total_kills", kills, true);
}

All platforms support a storeNow parameter: setStat("id", value, true) and setAchievement("id", true). When storeNow is true, the SDK schedules a persist immediately (debounced over 1 second). For an immediate flush, call storeStats() explicitly. The platform also flushes pending stats when the session ends.

Float stats

Use the float variants for stats that aren't whole numbers — distance travelled, completion percentages, best times.

WavedashSDK.set_stat_float("distance_run_km", 42.195, true)
var distance = WavedashSDK.get_stat_float("distance_run_km")
Wavedash.SDK.SetStatFloat("distance_run_km", 42.195f, storeNow: true);
float distance = Wavedash.SDK.GetStatFloat("distance_run_km");
Wavedash.setStat("distance_run_km", 42.195, true);
const distance = Wavedash.getStat("distance_run_km");

Unlocking achievements

WavedashSDK.set_achievement("first_win", true)

func has_first_win() -> bool:
    return WavedashSDK.get_achievement("first_win")
Wavedash.SDK.SetAchievement("first_win", storeNow: true);

bool unlocked = Wavedash.SDK.GetAchievement("first_win");
Wavedash.setAchievement("first_win", true);

const unlocked = Wavedash.getAchievement("first_win");

Storing stats and achievements together

Batch stat updates and achievement unlocks, then send them in one call:

WavedashSDK.set_stat_int("total_kills", 200, false)
WavedashSDK.set_achievement("first_blood")
WavedashSDK.store_stats()
Wavedash.SDK.SetStatInt("total_kills", 200, storeNow: false);
Wavedash.SDK.SetAchievement("first_blood");
await Wavedash.SDK.StoreStats();
Wavedash.setStat("total_kills", 200);
Wavedash.setAchievement("first_blood");
Wavedash.storeStats();

Persistence events

The SDK raises an event after each storeStats() flush so you can show a confirmation, retry on failure, or wait to quit until stats are safely persisted. Unity separately raises OnCurrentStatsReceived after RequestStats() completes.

func _ready():
    WavedashSDK.stats_stored.connect(_on_stats_stored)

func _on_stats_stored(payload):
    if payload.get("success", false):
        print("Stats saved")
    else:
        push_warning("Stats failed to save: ", payload.get("message", ""))
void Awake()
{
    Wavedash.SDK.OnCurrentStatsReceived += data => Debug.Log("Stats loaded");
    Wavedash.SDK.OnStatsStored += data =>
    {
        bool ok = (bool)data["success"];
        Debug.Log(ok ? "Stats saved" : $"Stats failed: {data["message"]}");
    };
}
Wavedash.on(Wavedash.Events.STATS_STORED, (payload) => {
  if (payload.success) console.log("Stats saved");
  else console.warn("Stats failed:", payload.message);
});

Example: kill tracking

var session_kills: int = 0

func on_enemy_killed() -> void:
    var kills = WavedashSDK.get_stat_int("total_kills") + 1
    WavedashSDK.set_stat_int("total_kills", kills, true)
    session_kills += 1
    if kills == 1:
        WavedashSDK.set_achievement("first_blood", true)
private int sessionKills;

public void OnEnemyKilled()
{
    int kills = Wavedash.SDK.GetStatInt("total_kills") + 1;
    Wavedash.SDK.SetStatInt("total_kills", kills, storeNow: true);
    sessionKills++;
    if (kills == 1)
        Wavedash.SDK.SetAchievement("first_blood", storeNow: true);
}
let sessionKills = 0;

function onEnemyKilled() {
  const kills = Wavedash.getStat("total_kills") + 1;
  Wavedash.setStat("total_kills", kills, true);
  sessionKills++;
  if (kills === 1) Wavedash.setAchievement("first_blood", true);
}