5 minutes
Pooled Bullets
Last lesson, the gun started firing — the cooldown ticks and the muzzle flashes about fourteen times a second — but nothing flew. spawnBullet asks for a bullet with world.acquire('bullet'), and no bullet pool exists yet, so it hands back nothing. There is an easy fix, but it hides a problem. You could build a new bullet entity and a new sphere mesh on every shot. At fourteen shots a second, that hands the engine dozens of new objects each second. The engine has to allocate them, then garbage-collect them a moment later. All that extra work is what makes a cheap arcade game stutter. A pool fixes it: acquire draws from a set allocated once, at boot, and never again.
Declare the bullet pool
Bullets don't belong to the player or to any enemy — they belong to the whole scene. So you declare them as a pool blueprint: one scene entity carrying a Pool marker beside the components every bullet will wear. Add it to your scene:
The Pool marker is what makes this entity a blueprint instead of a live bullet: a pool of 48 slots, named bullet. The other two components are the template each pooled bullet carries — a sphere MeshPrimitive and a Bullet that knows the arena bounds. And because Bullet is a real top-level scene key here, its BulletSystem starts through the normal scene path. That is the one line that gets the bullets moving once they're in the air. No empty stub, no marker trick — the blueprint keys Bullet for real.
Continue reading
Unlock the Full Course
Every lesson, the runnable examples, and the finished build — yours to keep.