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.
1. Lay out the dive path
Section titled “1. Lay out the dive path”A path is a list of points the flier follows, measured from wherever the flier starts.
-
In the game file (
star-swarm.blend), add an Empty namedSwoopwith Add Component ▸ Arcade ▸ Path (or drag Path from the Simulacrum asset library). -
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.
-
Set
path.pointsto the dive asx,zpairs in metres, separated by spaces, starting at0,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 |
2. Fly it with followPath
Section titled “2. Fly it with followPath”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.
-
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 layerenemythat hitsship, taggedasset.primary = 1. -
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. -
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. -
Pick the mirror from its own position: an Expression
a < 0 ? 1 : -1on its x, into a Text node with the templateSwoop,{a},6.5. A left-side enemy swoops right and a right-side one swoops left. -
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. -
On contact with
shot, emitworld:enemy.killedwith its points (150, 80 or 50 by kind) and Destroy itself. On contact withship, emit it with 0 points and Destroy itself. Onworld:clear, Destroy itself. -
Press Build Cartridge in each enemy’s file, and in the files for the player’s shot and the enemy bullet.
3. Build the game file
Section titled “3. Build the game file”-
Add
data/rows.json: one row per formation row, with the enemy’sassetaddress, how many (count: 4, 8, 8, 10) and how deep (z). -
Add the ship: Sprite and Arcade Mover with
arcade.drive = move,arcade.layer = ship,arcade.hits = ebullet,enemyandarcade.grace = 2. Bindmove,fireandagainas in Alien invasion and list the five spawnables inspawn.preload. -
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 = -5andsprite.scroll = starSpeed. Turn the quad so the scroll runs down the screen. -
Write the rules: the formation from the rows table,
world:diveRollon a timer, two shots at a time (ashotscount, 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.
4. Build and play
Section titled “4. Build and play”-
Press Build Cartridge, then publish the game and its spawnables (Publish and share).
-
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.
Limits
Section titled “Limits”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.
What you learned
Section titled “What you learned”- The Path component holds a route as points relative to the flier.
followPathflies 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.