Metaplay AI
SamplesPricing

Ninja Time Trial: Plugging a real-time game into Metaplay

Jarkko Pöyry
November 23, 2026game-development

I built the core gameplay of a real-time precision runner, then plugged Metaplay in around it for accounts, opponents and progression without touching that core. Here's why I worked that way, the design that kept the core and Metaplay apart, and what building it with an AI coding agent taught me, dead ends included.

Ninja Time Trial is a one-button runner that plays in the browser at 60 Hz, with Metaplay handling everything around the core gameplay: the opponents, the progression and the check that a finish time is real.

Why build a hard real-time game on Metaplay?

I like twitchy precision games, the kind where a jump that lands a few frames late costs you the run.

I also wanted to try a particular way of working. What interested me was the core feel, so I'd build that first and get it right. Then I'd add Metaplay around it to turn the prototype into a proper game, with player accounts, game configs and LiveOps, without rewriting the core. A lot of games start out exactly that way, and I wanted to see how smoothly the second step goes.

A precision game is a good test because its core is nothing like a typical Metaplay game. In a merge or card game, each move is a player action that runs on the device and again on the server. A runner steps 60 times a second, and that's not what actions are built for. Squeezing it into actions would also mean rewriting the core around them. That's why the core keeps its own loop, untouched, and Metaplay wraps around it, which is exactly the split I set out to test.

A precision runner built around tight gameplay

In Ninja Time Trial, the ninja always runs forward, and you have one button. Hold it to charge a jump, and let go to launch. A course is a short climb up a hillside through pits, ledges, vines and slopes, split into segments by torii gates. One time trial, or run, takes about half a minute. Mistakes cost momentum rather than ending it, so you always reach the finish.

Each run is a race against three ghosts, which are replays of other players on the same course. The ghost racing is the part I borrowed from Hill Climb Racing, although the core gameplay is very different: Hill Climb Racing runs real-time physics, and this is a precision runner. At the end of each segment, you earn Orbs based on your placement, and Orbs buy Skills that change how your ninja moves.

That's about as deep as the progression goes, on purpose. Most of my development time went into finding the simplest core design that still demands precision, and making it feel good. That's the hard part of a game like this, and it's where the effort belongs. The SDK can handle the rest.

Everything around the core is deliberately minimal. All the content is available early, the economy is shallow, and there are no LiveOps events. If you took this sample further towards a shipping game, that's where you'd go deeper, and it's where Metaplay does the heavy lifting. The economy lives in game configs, and LiveOps events such as a Christmas or Halloween level would get pushed out from the dashboard.

How a real-time game connects to a Metaplay backend

The easiest way to explain the design is to follow a single time trial from start to finish. The game has two sides: Metaplay, which holds the player's account and progression, and the core gameplay, where the running happens. A run starts and ends with a handover between them.

Before the run, the Metaplay side picks what you'll play. The server takes a map from the set it's currently rotating and chooses three ghosts from that map's pool, paced against your own best time there. This gives you a challenge that matches your ability, hard without being hopeless. The server then hands the game client a ticket together with the opponents. The ticket is a single-use permission to play one time trial: it names the course, the rules version and the Skill you have equipped.

During the run, Metaplay stays out of the way. The run is its own fixed-step simulation and doesn't call the server at all. As you play, the client records each input and the simulation step it happened on. Your finish time on screen is provisional.

After the run, the game hands back to Metaplay. The client submits the replay together with the ticket, and the server plays the replay through the same simulation under the ticket's course and Skill. The time the server computes is the one that counts. An accepted run is committed to your account through an ordinary player action, which pays out your Orbs. A rejected one pays nothing and tells you why.

One run in three screens: racing two ghosts over a rope bridge, placing third at a torii gate, and the result board once the server has validated the run

So the 60 Hz loop never becomes 60 player actions a second. The player model holds what persists between runs, such as best results, Orbs and Skills, and the run only touches it at the start and at the end.

The server validates the replay inside the player's own entity. One run is a few thousand steps of fixed-point arithmetic, which is cheap enough to do inline. If load tests ever showed otherwise, the replay could move to a worker queue without changing who decides the result.

Server-side validation with a deterministic simulation

The whole scheme rests on determinism: the same inputs on the same course must produce the same run in the browser and on the server, down to the last step. The simulation uses fixed-point numbers and a fixed update order, and its randomness comes from the course description, never from anything local to the client. The client is a Blazor WebAssembly app, so the same C# simulation is compiled into both the browser build and the game server, and one replay produces the same run on both.

I went for complete determinism because it was relatively easy here, and I'd recommend it to anyone building something similar. Metaplay ships a fixed-point math library, and there are others around. Everything is easier when everything is deterministic.

Recomputing the run doesn't prove a person pressed the buttons in real time, because a client that knows the rules could generate a valid replay. What it does prove is that the time is possible. Nobody can submit a finish time the game can't reproduce, unlike old-school leaderboards where anyone with the right tools could post 99999. Short-lived, single-use tickets make generated replays harder, and the sample deliberately stops there rather than trying to detect automated play.

The bot client goes through the same path. In a load test, each bot opens a ticket, plays a full run with a scripted driver and submits the replay, so the server checks a bot's run exactly the way it checks a person's.

Ghost pools built on custom server entities

Every run needs three ghosts to race against, and they have to come from earlier runs on the same course. For that, each course has its own ghost pool on the server. The pool collects accepted runs from named players and picks the opponents for every new run. Until real players have filled a course's pool, a few scripted runners at different paces make sure you have someone to race on a fresh course. In a live game, real players would quickly outnumber them.

I first looked at Metaplay's async matchmaker for picking the ghosts, and so did the AI. It's built for matching against other players, but here you're matching against runs on a particular course, and a game like this can have hundreds of courses, each with its own pool. The async matchmaker wasn't the right fit for that.

So I built each pool as a custom server entity. There's documentation on creating them, and building the pool and the storage for its ghost records went smoothly with the agent.

Custom entities worked for course rotation too. A second one, the map registry, rotates which courses are in play. By default it rotates every four hours, and it keeps its state through restarts. The rotation period is a game config value, so it can change without a new build.

What building it with an AI coding agent taught me

This project was also an experiment in how far I could go with AI. I started with one long conversation that planned the work and ran subagents to implement it, and kept iterating on the core gameplay until it felt good. With the core in place, I moved on to polishing it and building the game around it. For that I switched to several conversations at once, each on a single issue such as the metaprogression design, a parallax effect or testing an obstacle design.

The backend was the smooth part. Accounts, the ghost pools and the server-side validation went together with very little friction. The core gameplay took the most work, and AI didn't change that. An agent can write the jump, but it can't feel it.

The best surprise was the level editor. I needed a tool for altering maps, because maps have to play well, and that needs a human touch. I asked for a level editor, and the agent built one into the client. Without being asked, it also connected the editor to the server, and whenever I edit a level, the server simulates runs through it and sends back reference times, so I can see straight away whether a change makes the level too easy or too hard. The server was already computing those times to seed the scripted runners, and the agent saw that the pieces were there and tied them together.

The part editor in Ninja Time Trial's developer tools, with a river crossing on the canvas and reference finish times for scripted runners at four skill levels

I put the editor in the client on purpose, so I can play a level myself right after editing it. The backend computes the reference times, but I also want to feel how a level runs. The editor doesn't save anything by itself. It gives me the course part as JSON, and when I'm happy with it, it goes into the game configs and gets published from there.

If you use AI blindly, it's easy to run into dead ends, and the AI can spend a long time getting itself out of them. When most of your interaction is helping it out of holes it dug, the work gets grueling. Roughly 80% of what it produces is good, but the bad 20% drags the rest down with it, and you may only notice late. That 20% is why you still need to review. To keep the pace up and let the AI run with it, I reviewed plans and designs during development, not code. But I'm an old-school engineer, and I couldn't ship code I hadn't read, so I went through it afterwards.

If I did it again, I'd plan the Metaplay side as carefully as the core gameplay. I was so focused on the core that I let the agent add whatever seemed necessary around it. The SDK can handle almost anything, but since I gave the agent no design constraints, it was free to pick an approach that worked but wasn't the best one. A clear picture of what I wanted from the backend would have saved me some of those dead ends.

Two smaller lessons. Some AI tools downgraded the model mid-session because a design about submitting race replays to a server looked like security work to them. "Race" and "replay" read like race conditions and replay attacks, so I learned to keep those words out of the design documents. And I'm not an artist. I tried AI tools for the art and couldn't make anything that looked good.

Try the Ninja Time Trial sample

The Ninja Time Trial sample page walks through its features and has the game ready to play. Play a few runs there, then open the source.

The interesting parts of the repository are where the game and Metaplay meet. Look at how a run starts, how the opponents are found, how control passes to the real-time game and back to Metaplay, and how that handover stays safe. Point your own AI tools at it and compare it with your own core loop.

Install the Metaplay CLI and start developing with the Metaplay Agent for free

On macOS, with Homebrew:

brew tap metaplay/homebrew-tap
brew install metaplay

On Windows, with Scoop:

scoop bucket add metaplay https://github.com/metaplay/scoop-bucket
scoop install metaplay

On Linux:

bash <(curl -sSfL https://metaplay.github.io/cli/install.sh)

Then paste this into your coding agent from an empty directory:

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.

FAQ

Can I add Metaplay to a real-time game without rewriting the game loop?

Yes. In Ninja Time Trial the core keeps its own loop and doesn't need Metaplay while you play. Metaplay steps in at the start of a run, with a ticket and the opponents, and at the end, when the server validates the replay and pays out the rewards.

Why not send every frame to the server as a player action?

Player actions aren't built for 60 steps a second, and it would mean rewriting the core around them. Ninja Time Trial keeps the core in its own loop and commits only the validated result in a single player action.

Does the simulation have to be deterministic?

For this approach, yes: the server has to get the same result from the same inputs as the browser did. Ninja Time Trial uses fixed-point math, a fixed update order, and randomness that comes from the course description rather than anything local to the client.

How much server load does validating every run add?

Very little. A run is a few thousand fixed-point steps, validated inside the player's own entity, and the replay could move to a worker queue if load tests ever called for it.