Skip to content

Tournaments (Unity)

FRVRSDK.Tournament covers timed competitive events with a shared starting payload and a shared leaderboard. Pairs naturally with end‑of‑match flow: call CreateOrPostScore after every run and the player is either creating a new tournament or extending their entry in the current one.

if (!FRVRSDK.Tournament.IsSupported()) return;

bool canCreate = FRVRSDK.Tournament.IsSupportedAPI("create");

Sandboxed / server‑less channels won’t support tournaments at all. Individual actions (create, invite, …) may be gated separately — check IsSupportedAPI before wiring a button.

FRVRSDK.Tournament.PostScore(
    tournamentId: "26406699882334539",
    score:        1500,
    () => Debug.Log("Score posted"),
    err => Debug.LogError(err));

Create does not take a score — it just creates the tournament. To post the player’s first score in the same flow, use CreateOrPostScore below.

string payload  = "{\"seed\":12345,\"mode\":\"endless\"}";
long   endTime  = 1774907214000L;   // ms since epoch. 0 = default (2 weeks)

FRVRSDK.Tournament.Create(
    payloadJson: payload,
    title:       "Weekend Rush",
    sortOrder:   "HIGHER_IS_BETTER",   // or "LOWER_IS_BETTER" for time trials
    endTime:     endTime,
    tournamentId => Debug.Log("Created: " + tournamentId),
    err => Debug.LogError(err));

payloadJson is free‑form JSON — every participant gets the same string, so use it to seed the run.

End‑of‑match helper: CreateOrPostScore

Section titled “End‑of‑match helper: CreateOrPostScore”

This is the call you want from “you died, show a score screen”. If the player isn’t in a tournament, the native dialog offers to create one; if they are, their score is submitted. One call, right behaviour in both states. Note the argument order: endTime comes before score in the C# signature.

FRVRSDK.Tournament.CreateOrPostScore(
    payloadJson: "{}",
    title:       "Tournament",
    sortOrder:   "HIGHER_IS_BETTER",
    endTime:     0L,                  // ms since epoch; 0 = default 2-week end time
    score:       1500,
    resultJson =>
    {
        // { "action": "created" | "posted", "tournamentId": "..." }
        Debug.Log(resultJson);
    },
    err => Debug.LogError(err));

The result JSON deserializes into CreateOrPostScoreResult { string action; string tournamentId; }.

Current tournament (the one the player is in, if any). TournamentInfo has id, created, startTime, endTime:

FRVRSDK.Tournament.GetCurrentTournament(
    json =>
    {
        var t = JsonUtility.FromJson<TournamentInfo>(json);
        Debug.Log(t.id);
    },
    err => Debug.LogError(err));

Player’s full tournament list:

FRVRSDK.Tournament.GetMyTournaments(
    json =>
    {
        var list = JsonUtility.FromJson<TournamentInfoArray>(json);
        foreach (var t in list.tournaments) Debug.Log(t.id);
    },
    err => Debug.LogError(err));

Active tournaments surfaced by the host platform — these come back as PlatformTournament with richer fields (title, type, players, …):

FRVRSDK.Tournament.GetActiveTournaments(
    json =>
    {
        var list = JsonUtility.FromJson<PlatformTournamentArray>(json);
        // list.tournaments[i].title, .platformType, .players, .startTime, .endTime, …
    },
    err => Debug.LogError(err));
FRVRSDK.Tournament.Join("26406699882334539",
    () => Debug.Log("Joined!"),
    err => Debug.LogError(err));

FRVRSDK.Tournament.Leave(
    () => Debug.Log("Left!"),
    err => Debug.LogError(err));

string options = JsonUtility.ToJson(new
{
    image = imageBase64,
    text  = "X invites you to a tournament!",
    cta   = "Play Now"
});

FRVRSDK.Tournament.InvitePlayers(options,
    () => Debug.Log("Players invited!"),
    err => Debug.LogError(err));

image is a base64 data URL — same shape as Social.Share.