This was the first sprint on the new team for me. I had an idea what I would be working on for this game, so once the sprint started, I got to work on the new AI system for enemies. I was planning to add path finding and path following, and after I completed these I started on a state system and a system that holds common AI data. I got a lot done, and some of it could make its way into the game soon.
There was already a grid system for path finding in the game before I joined. There was even a path finding script, leftover from a system that was no longer in the game. I used the grid for my new path finding system, but I didn’t use the old path finding script, because I wanted to use flow fields. The old system used A*, which is more efficient in open spaces, but less effective in mazes or maze-like levels, like the ships in the game. Flow fields are also more effective when multiple enemies will be targeting a single point. As enemies will mostly need to target the player, it makes sense to make a single flow field that every enemy can use to track down the player.
Again, there was already a system in place for following paths. It didn’t use physics, and instead just traced a curve it made between the points. I replaced it with a physics based system, using steering functions to allow for more flexibility in the future. This means that I can add additional steerings to be used at the same time, so I could have enemies that track down the player and also flock to avoid crashing into each other or avoid obstacles.
This system is something entirely new that I added. You can add states to an enemy, set it up with conditional transitions, and give each state its own steering functions (such as path finding), all within the editor. It is currently a messy system to work with, but I was able to make an enemy that path finds to the player, switches to charging directly at the player on sight, then path finds back to its home when its battery charge is low, which is a system that we are planning on using for an enemy.
Another new system, this script holds the data for where the player was last seen, a flow field to that point, and in the future will hold other data that enemies can use to organize among themselves. This is helpful for enemies that can communicate with each other, so that when one of them sees the player, all of the enemies now know where the player is and can hunt them down. It also saves time and memory to have this data evaluated and held in one common place, instead of duplicated between the enemies. This system might not be used for every enemy, because some will probably intentionally be left out of the loop, but it will almost certainly be used for some enemy types, because it’s too cool not to use. It also makes sense, because the enemies are supposed to be robots used to defend the ship. Some of them should have the ability to communicate and organize.