Skip to content
b2craft
← Build log

Porting a game from a web prototype to Unity with AI agents

Our first port translated the code line by line and felt wrong. The second treated the web build as a spec and rebuilt the game from scratch.

By Buğra Güney4 min read

Update, December 2026: Smashyard is on the shelf. In December our game lab checked the market and found no evidence that physics destruction games hold a place in the mobile puzzle charts. The lessons below still hold. The full story gets a post of its own.

Smashyard is a pirate cannon physics puzzle: you fire at cargo stacked on enemy ships and try to knock all of it into the sea. It started as a web prototype. The version meant for the App Store and Google Play was being built in Unity.

We expected the port to be the easy part. Agents are very good at translating code from one language to another. That turned out to be the problem.

Why we prototyped on the web

The prototype is plain JavaScript: three.js for rendering, cannon-es for physics, bundled into a single HTML file. That setup gives agents a very short loop. They can change the game, run it in a headless browser, let a bot play a level and take screenshots, all in a few seconds and without a human in the way.

In three weeks the prototype grew to about 5,900 lines, with 1,200 generated levels across 12 worlds. It was good enough to play, test and change the theme twice.

Attempt one: translate it

The first Unity version was a direct port. Agents translated the web code file by file: the CSS interface became Unity UI, and the physics got patches so that Unity’s engine would behave like cannon-es.

It compiled, it ran, and it felt wrong. The interface looked like a web page inside a game. The physics behaved slightly differently in a hundred small ways, and every patch to fix one difference created another. After two days we deleted it and kept it under a git tag in case we needed something from it. We did not.

The lesson was not that the agents did a bad job. They did exactly what we asked. We asked for the wrong thing.

Attempt two: the web build is the spec

For the second attempt we wrote one rule at the top of the project instructions: Unity is a rewrite from scratch, not a port.

The web build became the specification. A reference document describes what the game does: how a shot feels, how the camera moves, what each screen shows, which numbers matter. Only three things carry over from the web code:

  • level data, as JSON
  • tuning numbers, such as shot power and gravity
  • design decisions, written down with the reason for each one

The code itself does not carry over. The test for “done” changed too. We put the two versions side by side and compare screenshots and behaviour, not code. The question is simply whether it is the same game.

The rebuild started on a single day: about 35 commits and 4,700 lines of C# for the core game, with the physics working the way the web version feels.

Giving the agent real tools

The first Unity attempt had a quieter problem. Agents compiled the project in Unity’s headless batch mode, and those builds kept failing on licensing. An agent that cannot compile is guessing.

We connected the agent to the running Unity Editor through an MCP bridge instead. Now it reads the real compile errors, runs the tests and makes builds in the same editor a person would use. The difference in quality was immediate, because the agent stopped writing code it could not check.

The same idea runs through the whole project. Agents do not get a description of the game; they get the game. A headless browser plays the web build, takes screenshots and reports what happened.

The physics engine tells the truth

All 1,200 levels are generated, not designed by hand. A generator proposes a level within each world’s rules. Then an expert bot plays it two or three times in a deterministic physics simulation. A level is rejected if the bot cannot finish it, needs more than 32 shots, or finishes in fewer than two. The number of cannonballs and the star thresholds come from how many shots the bot actually needed.

Across all 1,200 levels, the anomaly check found no physics problems. The rule we work by is short: the language model does not simulate physics, the physics engine does.

That rule mattered for the port. When we ran the expert bot against the first Unity version, it needed 27% more shots for the same levels. Same level data, different physics engine. If we had copied the ball budgets across, every level would have been harder than designed, and nobody would have known why. So ball budgets are measured again in Unity, never copied.

Small things that cost hours

Two bugs are worth sharing because neither shows up in code review:

  • Unity’s linear colour space changed how the semi-transparent interface colours blended. Panels that were dark blue on the web came out brown.
  • The cube mesh we generated had its triangles wound the wrong way on two sides, so the top and bottom of every crate were invisible.

An agent fixed each one in minutes once it was found. Finding them was the slow part, and both were found by comparing screenshots side by side. That is the kind of check we now run on every change.

Where it stood in October

The web build was about four weeks ahead of Unity. Unity had the core physics and the level format. The pirate theme, the screens and the store integrations were next.

If you are porting with agents

  • Rebuild against a spec instead of translating code. Agents will translate faithfully, including everything that does not fit the new platform.
  • Keep the old version running as the reference and compare behaviour, not source.
  • Give agents the real tools: the editor, the test runner, a way to see the screen. An agent that cannot check its work will write work that does not check out.
  • Re-measure anything that depends on the engine: physics, timing, colour, input. Do not copy numbers across.