Austral Factory
Back to the Factory

Factory · 01

Slice-Smash — a 3D tennis game in the browser

A Unity 6 tennis game played in the browser, with its own ball physics at 480 Hz, AI opponents and online 1v1.

Status
Beta
Year
2026
Technologies
14
physics step
480 Hz
worst-case shot solver
3.3 ms
WebGL build, Brotli
~11 MB
numbered decisions
183

A Unity 6 game compiled to WebGL, launched from a React portal. Single-player against AI opponents, career and tournament draws, and online 1v1 — no menus inside the game, by rule.

Stack

Frontend
  • Unity 6 (WebGL)
  • C#
  • React
  • TypeScript
  • Tailwind
Backend
  • Python
  • FastAPI
  • SQLAlchemy
  • WebSocket relay
Data
  • PostgreSQL
Infrastructure
  • Docker
  • Cloudflare
  • GitHub Actions
  • uv

Structure

Browser Cloudflare Mac at home · Tunnel React portal Portal match setup Unity WebGL Game physics 480 Hz Pages Function Edge proxy Access token FastAPI API launch JWT · checks Relay Online 1v1 WebSocket · no DB PostgreSQL 17 Database results · tuning Career sim Career draws AI vs AI More relays Other regions routed by ping
Structure — components and dependencies Hover a component to trace its links Swipe to see the whole plate

Architecture

A web portal that hands off to a WebGL game, an API that trusts nothing, and a relay that only moves frames.

Key decisions

  • The game has no menus: everything is set up in the portal, and a build validator fails if a menu sneaks into the game.
  • Matches start from a single-use launch token; the game claims its config, tuning and sound slots from the API, then reports back.
  • The relay is a separate process with no database, so API work never delays a game frame.
  • Tuning lives on the server: values are drafted, published and rolled back from the admin, never rebuilt into the game.
Path of a request
  1. 01 Portal React 19 Match setup. Opens the game tab first so popup blockers let it through.
  2. 02 Edge Pages Functions Keeps one origin: forwards /api and WebSockets through the tunnel with a service token.
  3. 03 API FastAPI Sessions, single-use launch tokens, tuning, and result checks before saving.
  4. 04 Game Unity 6 WebGL Plays the match, posts the result, tells the portal and closes its tab.
  5. 05 Relay WebSocket Online 1v1: passes frames between host and guest, nothing else.
  6. 06 Database PostgreSQL 17 Players, results, career draws and published tuning.

Under the hood

Constraints, optimisations and choices.

  • Choice

    No Rigidbody, own physics

    Deterministic ball physics in double precision, stepped at 480 Hz, with Magnus effect, spin and surface restitution. Pure C#, tested with dotnet test, no Unity in sight.

  • Optimisation

    Shot solver: 26 ms → 3.3 ms

    The worst case of the shot solver used to eat more than a frame. Now it fits comfortably in one, even on a phone.

  • Constraint

    A tennis court in about 11 MB

    No splash screen, high managed stripping, IL2CPP size optimisation, link.xml to keep the JSON classes, files served pre-compressed.

  • Trick

    Netcode that favours the hitter

    A shared clock between both games and lag compensation on the shot. Positions at 30 Hz during points, 10 Hz between; oversized or too-frequent frames are dropped.

  • Constraint

    Trust no client

    Results are checked on the server — valid score, plausible duration, consistent stats — and online, a result only counts if both games report the same one.

  • Optimisation

    Phones stay cool

    Adaptive render scale and an automatic FPS cap to save battery. Touch controls follow the thumb's arc.

AI integration

AI on court, and in the workshop.

There is no LLM inside the game. AI is in the opponents, in the simulation, and in how the thing was built.

  • AI players use the same controller as humans, so they can't cheat physics. Each one has a personality and a difficulty.
  • A Python point-by-point simulator plays the AI-vs-AI matches of career draws; a balance bench pits archetype bots against each other.
  • Athletes are generated by headless Blender scripts; stadiums and crowds are built in code with a custom crowd shader.
  • Built with Claude Code, with Unity MCP driving the editor and Blender MCP for hand animation.

Scalability

Small infrastructure, clear next steps.

Today the backend runs on a Mac behind a Cloudflare Tunnel and Cloudflare Access, with the site on Cloudflare Pages. Cheap, private and enough for an invited group — and each bottleneck already has a documented way out.

  • Extra relays can run in other regions on free VMs; each match goes to the relay where the slower player has the lowest ping.
  • The in-process rate limiter is the documented place to swap in Redis.
  • Relay rooms live in memory, one worker per process — next steps are a binary wire format and maybe Durable Objects.
  • Invite-only sign-up, admin behind TOTP two-step sign-in.

Want something similar for your product?

Let’s talk
Let's Talk
Palette

Colour palette

Change the mood of the site. Your choice is saved in this browser.