Skip to content

Star swarm

For creatorsAdd-on 2.2.2+

In this tutorial you build a formation shooter where enemies break away, dive along a path, fire on the way, and fly back to their place in the formation. It reuses everything from Alien invasion and adds one thing: the Path component and the followPath method that flies it. This builds on tutorial 7, Alien invasion.

▶ Play the finished game: ← → move, Space fires (two shots at a time), Enter plays again. On a phone, hold a finger to one side of the ship to move it, and tap to fire.

A path is a list of points the flier follows, measured from wherever the flier starts.

  1. In the game file (star-swarm.blend), add an Empty named Swoop with Add Component ▸ Arcade ▸ Path (or drag Path from the Simulacrum asset library).

  2. Plan the dive with a Bezier curve in Blender’s top view, starting at the flier’s slot: out to the right, down past the player, a loop, and a climb back.

  3. Set path.points to the dive as x,z pairs in metres, separated by spaces, starting at 0,0. The points are relative to the flier’s home, so one path serves every enemy in the formation.

Tag Value What it does
path 1 Marks the Empty as a path
path.points 0,0 0.14,-0.08 0.27,-0.17 … The path’s points, x and z in metres, relative to the flier’s home

Every Arcade Mover offers followPath. Call it with Call Component and a text argument: the path’s name, a mirror (1 or -1) and a speed in metres per second, such as Swoop,1,6.5. The body flies the path from its home slot, mirrored if asked, colliding as it goes, then flies exactly back home and stops. While it is already flying, a second call returns false.

  1. Build each enemy (swarm-drone, swarm-wasp, swarm-chief) as a spawnable: a two-frame Sprite lying flat (sprite.face = y) and an Arcade Mover in the layer enemy that hits ship, tagged asset.primary = 1.

  2. Give it an Asset-scope graph that starts with On Message world:diveRoll. The rules send it about every 0.9 s, sooner in later waves.

  3. Roll a Random Range and Branch on an Expression a < 0.02. Each enemy rolls its own numbers, so two or three dive at once.

  4. Pick the mirror from its own position: an Expression a < 0 ? 1 : -1 on its x, into a Text node with the template Swoop,{a},6.5. A left-side enemy swoops right and a right-side one swoops left.

  5. Call Component (Self, followPath) with that text. If the dive started (its Result is true), Delay 1 s and Spawn a bullet where it is now.

  6. On contact with shot, emit world:enemy.killed with its points (150, 80 or 50 by kind) and Destroy itself. On contact with ship, emit it with 0 points and Destroy itself. On world:clear, Destroy itself.

  7. Press Build Cartridge in each enemy’s file, and in the files for the player’s shot and the enemy bullet.

  1. Add data/rows.json: one row per formation row, with the enemy’s asset address, how many (count: 4, 8, 8, 10) and how deep (z).

  2. Add the ship: Sprite and Arcade Mover with arcade.drive = move, arcade.layer = ship, arcade.hits = ebullet,enemy and arcade.grace = 2. Bind move, fire and again as in Alien invasion and list the five spawnables in spawn.preload.

  3. Add the star field: one tile of stars drawn so its edges meet when repeated, on a flat Sprite with sprite.tile = 4, sprite.face = y, sprite.order = -5 and sprite.scroll = starSpeed. Turn the quad so the scroll runs down the screen.

  4. Write the rules: the formation from the rows table, world:diveRoll on a timer, two shots at a time (a shots count, lowered by each shot’s On Destroy), a life lost to a bullet or a diving enemy (only while playing), and the next wave when the swarm is cleared.

  1. Press Build Cartridge, then publish the game and its spawnables (Publish and share).

  2. Open it and wait a moment: an enemy peels away from the formation, dives past your ship, loops, and settles back exactly in its slot.

The add-on does not yet turn a Blender curve into path.points for you. Type the points yourself, reading them off your curve: x is Blender’s X and z is minus Blender’s Y, both measured from the flier’s start.

  • The Path component holds a route as points relative to the flier.
  • followPath flies it from home, mirrored if you ask, and brings the body back exactly home.
  • Text builds an argument from a template; Delay waits before the next step.

Next: Maze chaser paints a level in Blender and bakes it to data.