logo
By Lawrence

5 minutes

Add the Machine Gun

Course 1 gave you a fighter that flies anywhere but can't shoot. You can loop it, boost it, and chase your own trail. Nothing ever happens, because a flight model has no trigger. A shot has to leave the gun before it can hit anything. So the first thing you add is the gun that puts rounds in the air.

Add the gun to the ship

The player already has the whole flight stack. A gun is one more component on the same entity. Open the scene and add a line to Player.components, next to Transform6DOF, ShipFlight, and the rest:

        "MachineGun": {}

The object is empty, so every number uses its default. That one line does two things: the scene loader attaches a MachineGunComponent, and because the module also exports a matching MachineGunSystem, the system that runs it gets added for you. No cabinet wiring this lesson.

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