I worked on a few exciting tasks for BELTFED, all aimed at speeding up development and reducing the room for error in repetitive jobs.
When I started my work for Hello World Studios on BELTFED, the project was already well established. After a quick chat with Troy and Toby about where they wanted help, I was handed a nice long list of tasks, each with a deadline. I picked the ones I had capacity to finish in time and got to work.
Build automation
I started by putting together a single GitHub Actions workflow that builds the Unity project for Windows using IL2CPP. I had never built with IL2CPP before, and working through how its build pipeline differs from Mono's provided some useful learning. I knew there would be plenty of long and failed builds while I got every feature of the workflow working, so I did most of my testing on a self-hosted runner. Using my own hardware meant I could keep trying things without racking up costs for Troy and Toby. The workflow checks whether the self-hosted runner is online and falls back to a larger GitHub-hosted runner if it isn't, so a build never sits waiting for a machine that is switched off.
Later I expanded the workflow. Troy and Toby wanted it to cover all their target platforms and upload each build to a Steam depot for staging. One run now goes through the whole release:
- Check the repo settings and pick the version.
- Build all target platforms.
- Upload each build to its Steam depot and set it live on a password-protected staging branch.
- Commit the version bump and tag the release.
- Post the result to the team's chat via webhooks.
Because the workflow commits changes to the repo, I made sure that only happens once every build has succeeded.
Fighting for memory
Performance matters a lot in a game like BELTFED, so I had to balance build time against optimisation. IL2CPP's Master configuration produces the fastest code, but it gets there with link-time optimisation over the whole game at once. That turned out to be the hardest part of the whole task.
On Windows the linker ran out of heap space. Unity's builds run inside Docker with a memory cap, so I had the workflow add a page file on Windows or a swap file on Linux runners to cover the gap between the machine's RAM and the target. That stops a build from being killed by a brief spike. I briefly switched code generation to optimise for size, which made the build fit but gave up runtime speed. I discussed this with Troy and Toby, and we decided the performance loss was too much of a cost. We switched back to optimising for speed and let the extra page file cover the memory instead.
The other platforms we built for were worse. Unity's default link-time optimisation runs as one long pass over the entire game on a single core, so builds kept hitting the runners' memory caps and took hours, with some still linking long after they should have finished. I fixed this by switching those builds to ThinLTO. It does the same optimisation but splits the work across every available core, which uses far less memory and finishes much faster. That kept memory usage within the limits of the assigned runners with little to no loss in runtime performance. Without it, the runners would have cost too much to justify.
Keeping builds fast
Caching made a big difference. Unity's imported assets (the Library folder) are cached per platform, so a build only re-imports what changed instead of starting cold. The cache is only saved after a successful build, because restoring a failed build's half-finished import as if it were complete causes very confusing failures.
Builds from the Editor
Not every build needs to go through CI, so I added a build menu inside Unity. It builds for whichever platform is selected in Build Settings, downloads the matching Steam tools and can upload straight to Steam. It uses the same release settings as the CI build, so a build made on someone's desk is laid out exactly like one from the pipeline.
Analytics
Troy and Toby were keen to gather gameplay analytics. This task was especially exciting for me: I love game stats and what they show about how people really play, and I'm a strong believer in letting player feedback drive development.
I used GameAnalytics to collect a range of gameplay events. The brief was open: track whatever I thought would be useful. The one firm request was player retention funnels, mainly around the tutorial. I wanted the analytics to sit quietly in the background, so I set out with these goals:
- Avoid changing existing gameplay code wherever possible.
- Put the performance of gameplay code first in anything I wrote.
- Keep gameplay code free of any dependency on the analytics.
To meet those goals, I kept all the analytics code separate from the game itself. Rather than adding tracking calls throughout the gameplay code, I wrote lightweight trackers that observe the game from the outside. Removing the analytics entirely leaves the game untouched. Most events are batched rather than sent the moment they happen, which keeps the cost to performance low and stays within the service's limits.
The data gives the team a broad picture of how the game is played: how players get on with the tutorial, how far they get in a run, how they build up their factories, and how the game performs on their machines. That gives Troy and Toby real evidence to guide development decisions.
Getting the data right took some iteration. A few edge cases only showed up once real events came in, and working through them taught me a lot about making analytics trustworthy, not just present.
The hardest part was not getting carried away playing BELTFED, even after I'd finished testing all the events being tracked.
Documentation
Both systems are only useful if the team can use them without me, so I wrote documentation for each. The workflow docs cover every option, secret and cache, plus how to fix the common failures. The analytics docs list every event and how to explore it in GameAnalytics. They also include rules for keeping tracking up to date when new content is added.
My time working in education has shown me how important good documentation is. A job without documentation is only half done.
Wrapping up
Working with Troy and Toby was a blast. BELTFED is the game they were always going to make, and it's so great to see it finally coming together. Working with others on games and supporting people to do their best work is something I feel very grateful to be doing. Thank you, Troy and Toby, for letting me be a very small part of this project :)