logo
By Lawrence

5 minutes

A Field of Rocks

Course 2 ended in a real dogfight: two pilots hunting you, wings shearing off, missiles tracking. Fly away from them and the game empties out. Push the throttle in open space and the screen doesn't change. There is nothing out there for your speed to happen against. Boost feels the same as idle.

Rock fixes that, and rock is also what the rest of this course needs: something to hide behind, something to break a missile lock, something that kills you if you fly into it at 300 units a second. So the arena comes first.

Add the field and a landmark

Two edits. The first is one line on World, beside KeyboardInput and SpaceDust:

        "AsteroidField": { "count": 110, "seed": 1337 }

The second is a new entity after Enemy2, a derelict freighter parked far ahead, so you have one fixed silhouette to measure the field against:

    "Station": {
      "tags": ["station"],
      "components": {
        "Transform6DOF": { "x": 0, "y": -28, "z": 520, "rx": 0, "ry": 0.6, "rz": 0 },
        "Renderable": {
          "shape": "box",
          "sx": 90, "sy": 26, "sz": 90,
          "r": 0.42, "g": 0.46, "b": 0.52,
          "emissive": 0.06,
          "glbSrc": "/spaceshooter/freighter.glb"
        }
      }
    }

The station is the same Renderable shape you have used since Course 1, GLB and all. "shape": "box" is only the fallback silhouette if the model can't resolve.

The field is the clever half. AsteroidField sits on World rather than on a rock, because it isn't a rock: it's the recipe for a hundred of them. Nothing in the scene names a single boulder, and by the end of this lesson there will be dozens of asteroid entities that no JSON ever mentioned.

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