Metaplay AI
SamplesPricing

Sample game

Server-validated real-time runner sample

A one-button ninja autorunner that runs in the browser at 60 Hz, with the server validating every run to decide the time that counts.

Genre
Autorunner
Client
Blazor WebAssembly
Core Metaplay features
  • Replay validation
  • Custom server entities
  • Async multiplayer
  • Bot load testing
01

How this autorunner sample works

Ninja Time Trial is a one-button autorunner you play in your browser. The ninja always runs forward: hold to charge a jump, let go to launch, and climb a hillside course of pits, ledges, vines and slopes in about half a minute. Every run is raced against three ghosts taken from other players' accepted runs, and your placing at each torii gate pays Orbs that buy Skills, which change how your ninja moves.

It's the sample to study if you're building a hard real-time game, like a precision platformer or a twitchy shooter. The run is simulated in the browser at 60 Hz in its own loop, outside Metaplay's player actions. That loop could be any existing real-time game plugged into a Metaplay backend. When you finish, the client sends a replay, and the server plays it through the same deterministic C# simulation, so the time that counts is the one the server computed. A run it can't reproduce is turned down with a reason the player can read.

02

Core Metaplay features in the game

// racing_two_ghosts_over_a_rope_bridge

A real-time loop of its own

The run is its own game, simulated at 60 Hz on its own canvas. Metaplay handles your opponents and progression around it, from matching you with ghosts at the start to validating the run and paying out Orbs at the finish line.

03

What it shows about Metaplay

Each system in the game maps to a Metaplay feature. The label under each card names it and links to its page in the Metaplay docs.

Runs validated by replaying the inputs

After the finish, the client sends the run's ticket and everything the player pressed. The server plays that recording through the same simulation and records the time it computed, never a time the client reports. A recording it can't reproduce is rejected with a reason the player sees.

Server-authoritative game logic(Metaplay docs, opens in a new tab)
A deterministic real-time loop of its own

The run is a fixed-step simulation that sits outside Metaplay's player model and actions, built on Metaplay's fixed-point math so it is deterministic. The same C# is compiled into the WebAssembly client and the game server, so one replay always produces the same run on both.

Deterministic shared logic(Metaplay docs, opens in a new tab)
Single-use tickets and a result committed once

Each run starts with a short-lived ticket that names the course, the ruleset and the equipped Skill, so a recording can't be submitted twice for rewards. An accepted run is committed to the player exactly once through an ordinary player action.

Player actions(Metaplay docs, opens in a new tab)
Ghost pools seeded with scripted runners

Each course has a ghost pool on the server that collects accepted runs and picks the three opponents for every run. Until enough players have run a course, scripted runners at several paces fill its pool, so a placing means something from the first run.

Custom server entities(Metaplay docs, opens in a new tab)
Map rotation on a server timer

A map registry on the server rotates which maps are in play, every four hours by default. The period is a game config value, and the registry keeps its state through restarts and redeploys.

Persisted server entities(Metaplay docs, opens in a new tab)
Load-testing bots that play real runs

The bot client opens a ticket, drives a full run with a scripted driver and submits the recording, so a load test exercises the same server-side replay as a person playing.

Bot client(Metaplay docs, opens in a new tab)
04

Explore this sample

Two steps and your coding agent has this sample running locally and can walk you through how it fits together, from the shared game logic to the game configs and the LiveOps Dashboard.

Prefer to run it by hand? The README has the commands.

  1. macOS, with Homebrew
    $ brew tap metaplay/homebrew-tap
    $ brew install metaplay
    Windows, with Scoop
    $ scoop bucket add metaplay https://github.com/metaplay/scoop-bucket
    $ scoop install metaplay
    Linux
    $ bash <(curl -sSfL https://metaplay.github.io/cli/install.sh)
  2. 02Paste this into your coding agentFrom an empty directory. It clones the sample, installs the Metaplay Agent, runs the game locally and walks you through how it works.

    The Ninja Time Trial sample is at https://github.com/metaplay-shared/samples/tree/main/Samples/NinjaRun. Clone https://github.com/metaplay-shared/samples, go into Samples/NinjaRun and run metaplay skills install there to install the Metaplay Agent. Open a playable version of the game locally in my browser so I can try it, then walk me through how the sample is put together.

05

More samples

All samples→
Real-time multiplayer card sample gameplay

Card game

Real-time multiplayer card sample

A four-player real-time card game where the server owns every deal, with a full live-service layer around it.

Blazor WebAssemblyExplore→
Async PvP football sample gameplay

Sports management

Async PvP football sample

A head-to-head football manager league for 20 friends, with the meta of a top-grossing casual game around it.

Blazor WebAssemblyExplore→
Turn-based PvP collectible card sample gameplay

Collectible card game

Turn-based PvP collectible card sample

A two-player PvP collectible card game where the server runs every rule and both browsers replay the same C# actions.

Blazor WebAssemblyExplore→