Minimal Robotron-lite (Unity / C#)
The step-8 project in overview-arcade-classics-as-learning-projects and the final entry in the route. It covers the canon reference’s list for Robotron: 2084 (see source-classic-games-canon): twin-stick input, enemy steering, spawn pressure, and survival arenas.
Original project inspired by a recognisable pattern — not a clone.
Files
| Script | Responsibility | Key wiki concept |
|---|---|---|
TwinStickPlayer.cs | Move on WASD, aim/fire on the arrow keys (or mouse) | unity-input, unity-input-system |
Bullet.cs | Directional shot; kills an enemy on overlap | unity-collider2d-and-triggers |
Enemy.cs | Seek + separation steering toward the player | steering-behaviours |
RobotronGame.cs | Accelerating spawner, contact checks, score, lives | csharp-collections, unity-gamemanager-pattern |
ArcadeHud.cs (in ../shared/) | Shared on-screen HUD: a status line plus a timed centre message, drawn with TextMeshPro | ui-design, game-interface-types |
What the four step-8 ideas look like
- Twin-stick input. Movement and aiming are read from two separate key sets,
so you can run one way while firing another — the genre’s whole identity.
unity-input-systemdoes the same with a gamepad’s two sticks. - Enemy steering.
Enemyadds two Reynolds behaviours: seek (steer toward the player) and separation (push off nearby enemies). The result is a swarm that converges without clumping into one dot — see steering-behaviours. - Spawn pressure.
RobotronGameshortens the spawn interval with every spawn, so survival gets steadily harder the longer you last. - Survival arena. There is no goal but to live: the player is clamped inside the screen, enemies pour in from the edges, and contact costs a life.
Scene setup (about 10 minutes)
- New 2D scene, Main Camera set to Orthographic.
- Add a user layer
Enemy(Edit → Project Settings → Tags and Layers). - Bullet prefab: a small sprite with the
Bulletscript. Make it a prefab; delete the scene copy. - Enemy prefab: a sprite, layer Enemy, with a Circle Collider 2D and
the
Enemyscript. Set its Enemy Mask to the Enemy layer (used for separation). Make it a prefab. - Player: a sprite at the origin with the
TwinStickPlayerscript. Assign the Bullet Prefab and set Enemy Mask to the Enemy layer. (No collider needed — contact is checked by distance.) - Game: empty GameObject
Game, addRobotronGame, and assign the Player and the Enemy Prefab. - HUD: copy
../shared/ArcadeHud.csinto the project as well. Add GameObject → UI → Text - TextMeshPro (click Import TMP Essentials the first time). Unity also creates a Canvas (leave it on Screen Space - Overlay) and an EventSystem. Name the textStatusTextand anchor it to the top-left; duplicate it asMessageText, anchor it to the centre, and set its alignment to centre. AddArcadeHudto the Canvas, drag both texts into its Status Text and Message Text fields, then drag the Canvas into the Hud field onGame. (Leave Hud empty and messages print to the Console instead.) - Press Play. WASD moves, the arrow keys fire in their own direction (or hold the mouse button to fire toward the cursor). Survive as long as you can; score and lives show on screen.
How this closes the route
Robotron reuses almost everything earlier steps taught — direct movement, vector maths (Asteroids), poolable projectiles (Space Invaders), enemy bookkeeping, and a game-state owner — and adds the one big new idea, steering, which is the gateway to the wider AI material: steering-behaviours, then context-steering, behaviour-trees, and the rest of the game-AI track.
Extension ladder
- Pool bullets and enemies — apply the object-pool-pattern from step 4 and watch the unity-profiler under heavy spawns.
- Enemy variety — a faster “chaser” and a slow “tank” using different steering weights; or wanderers that ignore the player (add a wander behaviour).
- Rescue targets — humans to collect for bonus points, as the original has.
- Juice — hit flashes, screen shake, and spawn telegraphs; the feedback layer from game-feel that makes a survival arena feel good.