logo
By Lawrence

5 minutes

Enemy Waves

Your two enemies are furniture. Enemy1 and Enemy2 are typed into the scene file at fixed spots, they exist from the first frame, and when you kill them the fight is over for good. Every arcade game solves this the same way: something decides when fighters appear and how many, and the ships themselves come from a pool that was set aside before the round started.

Add the director and the pool

WaveDirector goes on World, with no setup at all:

        "WaveDirector": {}

The empty object picks up the default schedule. The second entity is the pool it spawns from: the full dogfight kit you built across Course 2, declared once as a blueprint:

    "Enemies": {
      "tags": ["enemy"],
      "components": {
        "Pool": { "size": 32, "name": "enemy" },
        "Transform6DOF": {},
        "Velocity6DOF": {},
        "FlightIntent": {},
        "ShipFlight": {
          "maxThrust": 50, "boostMultiplier": 1.5,
          "turnRate": 1, "rollRate": 1.5,
          "linearDrag": 0.7, "angularDrag": 3
        },
        "Enemy": {},
        "AiPilot": {},
        "MachineGun": {
          "fireRate": 5, "bulletSpeed": 380, "bulletDamage": 1,
          "range": 320, "spread": 0.018
        },
        "ShipLoadout": { "loadout": "kilrathi" },
        "Renderable": {
          "shape": "kilrathi",
          "r": 0.52, "g": 0.18, "b": 0.16,
          "glbSrc": "/spaceshooter/bugship.glb"
        }
      }
    }

That is Enemy1's component list, minus its position, with a Pool marker on top. PoolSystem reads the other nine components as a template, pre-builds 32 parked copies, and consumes the blueprint. ShipLoadout mints each slot's Parts and health when it attaches, so all 32 arrive fully built, with hitboxes, HP and gun in place, before the first frame renders.

Continue reading

Unlock the Full Course

Every lesson, the runnable examples, and the finished build — yours to keep.

$9one-time

Was this page helpful?

We read every note — tell us what's working and what isn't.

↑↓ NavigateEnter SelectEsc CloseCtrl+K Open Search