Search our shop

JFK Løvlien's Unity boss fight in The Magus: the demon with the flintlock pistol inside the ring of flame stakes on the beach, built with Claude Code for iPhone
AI game development1 min read October 24, 2026

Unity Boss Fight on iPhone: Four Days to Build Her, Ten Seconds to Kill Her, and the Five Bugs In Between.

A demon with a flintlock pistol, rounds you can see and dodge, three phases, and five bugs the test harness could not see. Then I killed her in ten seconds on camera.  

A demon with a flintlock pistol, rounds you can see and dodge, cover that works, three phases, and the mistakes that came out of the phone instead of the harness. Written for Unity builders, with the numbers.

This is the account of one boss fight in The Magus, my pirate game for iPhone, built in Unity 6 with URP, Forward+ and Metal, on an eight gigabyte MacBook Air. The fight was designed on paper from the rules the Assassin's Creed games follow, built headless by Claude Code in four days, proven letter by letter in a test harness, and then played by me. She worked. Five things around her did not, and every one of them was something the harness could not see and the phone showed in a minute. Then I filmed it for the weekly video, forgot I was supposed to make the fight last, walked up with the big gun and killed her in ten seconds. If you are building a Unity boss fight for mobile, the design is here, the bugs are here, and so is the cost of it in time and tokens.

TL;DR
  • The design: a telegraphed shot (a red line 0.8 seconds before the flash), a visible round at 16 metres a second you can sidestep, three rounds then a 3 second reload that is your window, cover you crouch behind, three phases at 30, 18 and 8 health, a checkpoint at the arena's edge.
  • The build: Claude Code, headless, an item at a time, each one proven by a scenario that presses the real controls, then a buttons test that must read zero dead presses before any build.
  • The five bugs the phone found: a checkpoint that teleported the player across the island, a stick that forgot your thumb every time a new area loaded, a door hung as a fin you could walk past, a guard who blocked a musket ball with his sword, a shotgun mounted backwards.
  • Why the harness missed them: the Editor keeps input state a phone drops, a line is not a trigger, a flag set at a chat's close is not set when the player walks off, and a scene load is not a lift of the thumb.
  • The cost: a three hour block of Claude Code eats about a quarter of a weekly budget. Run counts instead of minutes and a lighter regression gate brought it down.
  • The ten seconds: a lesson about filming, not about the fight. The rebuild (bigger, glowing, fireballs, hunting dogs) is the next post.

Table of Contents

The Fight on Paper

The brief to myself was one line: an Assassin's Creed boss, on a phone, with a pistol. That genre has rules, and they are worth writing down before a single prefab is placed. Every attack is telegraphed the same way every time. The player always has one safe answer available. A phase adds a pattern, never just more health. Pickups sit where the player is meant to stand. The arena reads at a glance. And the boss has one weakness the player can learn, which here is the reload.

So she got a flintlock pistol and a cadence: aim, a red line from her muzzle to the player for 0.8 seconds with a hammer click, the flash, one round. Three rounds, then a reload of 3.0 seconds with her hands busy, which is when you shoot her. Her rounds are not hitscan. They are objects, 0.15 metres across, emissive, flying at 16 metres a second, so a player twelve metres away has 0.75 seconds of flight on top of the 0.8 seconds of warning. Strafe at the line, not at the flash, and it misses. Stand still and it costs two of your ten health. That is fast but not impossible, which was the whole instruction.

The boss is a free Asset Store character with her own fighting animations, a Demon Girl, scaled to 1.15 and stood in front of a strongbox on two barrels at the water's edge. She came with a pistol in her hand, which decided the fight.

The Arena

The arena is a ring on the sand, radius 14 metres, marked by sixteen flame stakes and a line, centred seven metres inland of her stand. Four low rock walls at six to nine metres, 1.1 metres high, and four stones you can crouch behind. The player's entry point sits fourteen metres inland. During the fight the ring holds you: step past the edge and you are moved one metre back inside through the character controller, never by setting a transform. Before the fight and after her death the ring is open.

Finding the site was its own job. The first version was placed by a search that ran with the neighbouring city scene unloaded, and the arena landed on top of the city's sea wall and railings, invisible to the search and solid in the game. Her phase-three rounds hit a wall piece standing at her muzzle. The second search loads every scene the loader would load there and casts a box over the arena, half extents ten by four by ten, and refuses any site where a collider that is not terrain, sea, player or the arena's own answers. Twenty-seven candidates along the shore, twenty-two clean, the nearest clean one taken, twenty metres from the first. Every builder tool I write now carries that rule: search with the neighbours loaded.

The Telegraph and the Rounds

A round is a small sphere with a sweep. Each frame it moves its 16 metres a second and casts a sphere of radius 0.5 along the move. Whatever it meets first ends it: the player's character controller for a hit, a wall or a stone carrying a Cover marker for a cover hit with a burst of chips, the sand for a puff, or nothing for a miss. The sweep prints what it met with the full path, the scene the collider lives in, its layer, whether it is a trigger, its bounds and the hit point. That line is what found the sea wall. It is cheap to print and it has paid for itself every day since.

The telegraph is a line renderer from the muzzle to the player's chest, red, for 0.8 seconds, with a click. Phase three shortens the aim to 0.6 seconds, fires two rounds a volley 0.25 seconds apart at 20 metres a second, and every volley knocks one of your walls down. The line is the player's cue. The harness proved the strafe twice: started at the flash it took the round in the face; started at the line it cleared it by eleven metres. The number on the screen is the one the player has to learn, and 0.8 seconds turned out right.

Cover, Phases, Checkpoint

Three cover cases are proven every run. Crouched within 0.8 metres behind a wall: the round ends on the wall, no health lost. Standing behind the same wall: the round clears it and hits. The strafe window from twelve metres: a miss. Her damage is two per round; the pirate has ten.

Phase one, 30 to 18 health: the pistol cadence. Phase two, from 18: she walks at you at 1.6 metres a second, a light blow every 1.8 seconds you can block, a heavy every six seconds with a one second windup you cannot, the pistol in between. Phase three, from 8: the red sheet, the fast pairs. Her health bar sits top centre, 24 points from the edge, full the moment the fight starts. The blade reaches her, the musket takes two, the shotgun takes five inside eight metres, which is the weapon the mission tells you to buy, and the mission pays you enough to buy it.

Die and you return to the arena's edge with full health, her reset to 30, the pickups back, no cutscene the second time. The checkpoint is a flag with her entry point in its name, written when you cross into the arena and cleared when she dies. That flag is the first bug.

The Five Bugs the Phone Found

1. The checkpoint that crossed the island. The checkpoint handler listened to the scene manager's load event, any scene, additive district loads included, and placed the player at the checkpoint whenever the flag stood. The arena's first site sat on the route from a tunnel exit to the beach, with a trigger line forty metres wide. A player who freed a prisoner, climbed out of the hatch and ran for the beach crossed the line without knowing, the flag was written, and the next district that streamed in placed him at the boss's doorstep. On the phone it looked like a glitch that snapped you backwards. The fix: the district only exists once the mission that sends you there is active, the boss is inert before that flag, and the checkpoint handler answers a single-mode scene load only, never an additive one.

2. The stick that forgot your thumb. This one had been reported twice as "the pirate stops when a new area loads". The thumbstick script cleared its finger id on every scene load event, which again fires for additive loads. The thumb held through the load gets no new touch began, so the finger is never claimed again, and on a phone the reader zeroes the move vector every frame until you lift and press. In the Editor the last input is kept, so the harness read a pirate still walking and passed it. The fix: a scene load is not a lift; a finger that vanishes with no ended or cancelled phase is held for half a second with its last vector and re-acquired by the same screen area; a lock's release resamples the live touch. Proven across an activation, a forced 400 millisecond frame stall and a dropped touch, speed equal before and after.

3. The door that was a fin. The country house's locked front door could be pushed through. It had a solid collider, enabled, the right layer. The pack's door pivot sits 0.65 metres in front of the slab, and the leaf had been hung by that pivot at ninety degrees, so closed, the slab stood on the doorway's centre line perpendicular to the wall, a fin you walk past on either side. The scenario only ever read "is open", never "is in the way". Now a hinge at the jamb carries the leaf in the wall plane, and the proof pushes the stick into the locked door for two seconds and reads the distance moved.

4. The guard who blocked a musket ball. A guard in the tunnel took a ball to the face and nothing happened. The guard's hit code rolls a block for any hit that is not a sword cut, written for fists, and a ball is not a sword cut. Armed, in combat, facing you, he parried a musket ball with his cutlass. One condition: the block branch takes melee only.

5. The shotgun mounted backwards. The mount tool guesses the muzzle end of a gun from its mesh, the thinner end. The shotgun's two halves measured identical, the guess went the wrong way, and the pirate held it stock forward with the pump at his hands. The retry measured by a different rule, mounted it end for end the other way, rendered a still, saw it was still wrong, and reverted itself. A mesh heuristic cannot know which end is the barrel. It is a fact per gun and it goes in the item's data.


What the Harness Could Not See

The build runs through two AIs: one designs and writes the brief, one executes inside the Unity project with the Editor closed, and I play the build on the phone. The executor proves every item with a scenario that presses the real controls through synthetic touch, and a buttons test presses all nine controls in seven places and must read zero dead presses before any build is made. That caught dozens of things. It did not catch the five above, and the reason is the same each time: the scenario proved the sentence in the brief, not the thing the player does.

The entry trigger was a line. The brief said "crossing the line starts the fight" and the proof crossed the line. The player came along the beach from the side and never crossed it. Now the ring itself is the trigger, from any direction, and a player placed inside it triggers on the first frame.

The flag that unlocked the next character was set when a chat closed. The proof tapped the close chip. The player walked off while a mission screen paused the game over the chat, the chip was never tapped, the flag was never set, and the next character told him to piss off. Now a state's flags are set the moment its line opens, and the mission screen waits until no chat is open.

The door proof read the open flag. The stick proof read the pirate's speed. Both were true in the Editor and false on the phone. The rule that came out of it: a proof measures what the player would see, position and distance and the controller's own velocity, and never a flag the code set for itself.

The Budget

I will be honest about the price. A three hour block of Claude Code, twenty items, costs about a quarter of a weekly plan. Two things made the blocks long. The regression gate ran after every item, five minutes each, close to two hours on its own. And when a proof failed on the scenario's own mistake, the executor patched the scenario and ran the whole chain again to check, ten minutes a lap, with the full log read into context each time. By Thursday the week's budget read 83 percent used.

Three changes fixed it. Run counts instead of minutes: one run per proof, one scenario fix and one rerun, then the item goes to the needs list, never a third lap. Logs read by grep for the pass and fail lines, never whole. And the gate only after an item that touches controls, a loader, a scene, a chat or the player's path; an item that touches sound, text or a material gets the block-end gate. The next two blocks ran at an hour and fifty-one minutes, with a safe copy of the last good build tagged and copied before either started, so that a bad block costs nothing but time.

The Ten Seconds

Then I filmed it. The plan was a long fight for the video: strafe, cover, the reload windows, the phases. I walked in with the shotgun, locked on, held the trigger, and she went down behind a cloud of powder smoke before the music had found its loop. Ten seconds. The fight that took four days was over in less time than the cutscene before it.

It is a filming mistake, not a design one, but it told me something true: a boss you can finish from the rim with one magazine is a target, not a fight. The rebuild is already written. She grows another twenty percent and glows so she lights the sand; the arena goes to eighteen metres and gets its own lights; she keeps her distance and fires three systems of fireballs, singles, pairs and fans of three; the pirate fights from the rim with four cover rocks and medpacks; and she sends hunting dogs, two at a time, four times a fight, while she keeps shooting. That is the next post.

If you want this shape of work on your own problem, the hour exists for it: a one hour call, $100. A full Nexus build is $4,999 plus $299 a month, enterprise from $9,999, scoped first. And if the honest answer after the hour is that you do not need me yet, you will hear that too.


What Went Into the Rules File

Every block the executor runs is governed by a rules file in the repo root. This fight added three laws and a habit.

Built sequences are frozen. Anything the player has walked on the phone does not change unless a brief names it, and a new district, arena or object is placed where no walked sequence passes, at least eighty metres from every stand and pin, and loads only while its own mission is active. The arena on the tunnel's doorstep is what happens without it.

Any fail is a dead press. The buttons test used to count dead presses only. A failing check line in it, the one that said the wrong district was loaded after the climb, was reported twice and let through. Now a fail anywhere in the test blocks the build the same as a dead press.

Run counts, not minutes. One run per proof, one fix and one rerun, then needs. Written to stop the laps, kept because it also makes the reports honest: a letter that is still failing is listed, not retried into passing.

The safe copy. Before a block starts, the last good build is tagged in git and copied on disk. The week I was away from the keyboard, that is what let me say "install the previous one" without a thought.

Unity Boss Fight: The Checklist

If you are building a boss fight in Unity for a phone, in this order:

1. Write the genre's rules down before the prefab. Telegraph the same way every time, one safe answer always available, phases add patterns, pickups where the player stands, a weakness the player can learn.

2. Make the projectile an object with a sweep, and print what it meets. Path, scene, layer, trigger, bounds, hit point. The line that costs nothing finds the collider you did not know was there.

3. Give the player a number to learn. Ours is 0.8 seconds of red line and 0.75 seconds of flight at twelve metres. Prove the strafe from the line and from the flash; only one should work.

4. Search for the site with the neighbours loaded. Cast a box over the whole arena and refuse anything foreign. Keep it away from every route the player already walks.

5. Trigger on the space, not on a line. A ring the player can enter from any side, and a placement inside it counts as an entry.

6. Set flags when a line opens, not when a chat closes. The player will walk off. The player will be interrupted by your own mission screen.

7. Treat every scene load event as additive until proven otherwise. Checkpoints, input state, anything that resets on load: additive district streaming fires the same event. Do not clear a finger id on it. Do not teleport on it.

8. Prove what the player sees. Distance moved into a locked door, the controller's velocity across a load, the round's hit path. Never the flag the code set for itself.

9. Count the budget in runs. One proof, one fix, one rerun, then the needs list. Read logs by grep. Gate the build after the items that can break controls, not after every line of text.

10. Film it after you have played it, with a plan for how it should go. Or make a video about the ten seconds.

Summary

  • An Assassin's Creed style boss on iPhone: a telegraphed pistol, visible rounds at 16 metres a second, three rounds then a 3 second reload, crouch cover, three phases at 30, 18 and 8, a checkpoint at the arena's edge.
  • Built headless by Claude Code in four days, each item proven by a scenario on the real controls and a buttons test that must read zero dead presses.
  • Five bugs the phone found in minutes: a checkpoint on every scene load, a stick that forgot its finger on every scene load, a door hung as a fin, a guard parrying a musket ball, a shotgun mounted backwards.
  • The common cause: proofs that measured the brief's sentence rather than the player's action, and an Editor that keeps input a phone drops.
  • The cost: a quarter of a weekly plan per three hour block, cut by run counts, grep-only logs and a lighter gate, with a tagged safe copy before every block.
  • The fight was killed in ten seconds on camera. The rebuild: bigger, glowing, fireballs, hunting dogs, an arena with its own light.

JFK Løvlien

JFK Løvlien is the founder of JFKAISLAY and the builder behind Nexus, a custom AI agent platform for businesses, and Jane SEO, an AI SEO agent for Shopify. He writes the Feeder Series thrillers and is building an iPhone game in their world. Norwegian entrepreneur, AI builder, and Shopify operator based in Santos, Brazil. Runs four live e-commerce stores. 100,000+ products optimized. Built production AI systems from scratch. Runs on Claude Max 20x.

Frequently Asked Questions

How do you make a boss's bullets dodgeable in Unity?

Make the bullet an object, not a raycast. Ours is a small emissive sphere moving at 16 metres a second with a sphere-cast along each frame's move, and a visible warning before it leaves the gun: a red line from the muzzle to the player for 0.8 seconds. The player's reaction window is the warning plus the flight, 1.55 seconds at twelve metres. Tune the speed and the warning, not the hit chance.

Why did the fight work in the test harness and fail on the phone?

Because the harness proved sentences from the brief: "crossing the line starts the fight", "the door is open", "the pirate's speed holds". The player came from a different side, pushed through a door that was never read as a wall, and held a thumb the Editor keeps and the phone drops. Proofs have to measure the player's action, distance moved, velocity, the projectile's hit path, and never a flag the code set for itself.

Does SceneManager.sceneLoaded fire for additive scenes?

Yes, for every load, with the mode in its second argument. Anything you reset in that handler, a checkpoint placement, an input finger id, will reset during additive streaming of a district the player is walking through. Check the mode, or do not reset there at all.

How much does building a boss fight with Claude Code cost?

In our setup a three hour block of twenty items costs about a quarter of a weekly plan, most of it in proof runs and log reads rather than code. Run counts instead of minutes, logs read by grep only, and a regression gate after the risky items rather than every item brought the next blocks to under two hours.

Where should cover go in a boss arena?

Where the player is meant to stand, with a clear line of fire to the boss from each piece, and nothing in the middle to hide behind, so the pressure stays on. Prove the line of fire from every stand; our first arena had the city's sea wall standing invisibly at her muzzle until a sphere-cast printed its path.

What is the one habit from this that transfers outside games?

Freeze what has been walked, place new things away from it, and keep a tagged copy of the last good build before every session. The arena on the tunnel's doorstep broke a sequence that had worked for weeks; the tag is what makes a bad day cost only the day.

Share