logo
By Lawrence

5 minutes

Add the First Enemy

Last lesson the gun started working. Hold an arrow key and bullets stream out, hit the cover walls, and recycle back into the pool. But they fly through empty air — nothing in the arena can take a hit. It's time to build an enemy.

But the enemy isn't a single thing you drop next to the player. You placed the ship once, and it's one capsule; the finished game has dozens of enemies, coming from a pool, spawning in waves, each one a fully animated robot. That changes how it gets built.

So this lesson builds the enemy's three parts — the robot model, the animator that plays its clips, and the brain that decides what it does — without putting a live enemy in the arena. Spawning the waves is the pool's job (Lesson 7). By the end, every enemy system is registered and standing by for the moment a robot spawns.

Load the enemy model with Mesh

The player is a MeshPrimitive, a built-in capsule shape. The enemy is a real model — the shooter robot GLB, with Walking, Punch, and a set of death clips baked in. Back in Lesson 1, bjs download scene TwinStickArena --all already put it in your project at public/shooter-shooter-bot-1/shooter-bot-1.glb. The Mesh component loads a file like that through the renderer. Two of its flags make a big swarm cheap:

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