Shooter AI
Giving our ground units simple brains… and then handing them guns.
Earlier this year, we prototyped some rough artificial intelligence (AI) and pathfinding stuff for both ground and air units. This month, we finally put some of that to good use and began building the foundational components for what will be a complex AI system that will allow for an extraordinary amount of emergent gameplay.
We decided to focus on ground units first, since they’re considerably less complicated than flying stuff. Then we narrowed it down further to just focus on shooters, since they’re simpler than physics-based melee characters.
Step 1: Fight or Flight
First, we added some basic obstacle avoidance to our physics-based ground locomotion. Then, we gave our NPCs Behavior Trees and began adding some basic logic, like when and how to fight, flee, or just drop dead.
This wimpy cop is pretty scared of pigeons, so just getting too close is enough to send him running!
Step 2: Projectiles
After that, we made the NPCs start shooting at stuff. For these initial tests, we just gave the characters imaginary guns, animated them throwing junk, or made them shoot projectiles from their mouths like the pigeon—cuz we’re “lazy devs” like that lol.
Next, we allowed projectiles to use our DNA System, meaning each shot could impart special effects on collisions, like burning, freezing, or transforming the target. In this case, we just injected some “Enlarge” DNA, turning hit NPCs into giants for a limited time. Cuz… well… why the hell not, right?
Optimization is super important for this project, so naturally we stress-tested things by spawning dozens of these special peeps and making them all hit each other. Silly scenes like this just fill our gamedev hearts with joy.
Step 3: Guns
Finally, we gave our little creations some guns and IK animations so they could properly aim and shoot at our poor little pigeon… sometimes resulting in friendly fire. Officer down!
We had a lot of fun playing around with different levels of accuracy/damage here, and coming up with ingenious ways to circumvent gunfire, like using rubble as a shield. Ping ping!
Next Up: Melee Attackers
Now that we’ve got a basic shooter system in place, the next step is to add melee attacks to the mix!