As Smart As I Can: Enemy AI


Generating the AI states for the enemy took significant consideration of what they were going to do and how they were going to do it. On the top of my head, I knew I needed to make a state for them to wander around, chase and attack the player, and die. Additionally, since I wanted them to compete for resources with the player, I needed to make my enemy collect pickups like a player would.

The wander and die states were pretty easy to create, while the chase, attack, and collect states created a couple of obstacles for me. While juggling all the colliders the enemy needed with player's collider, and pickup colliders I needed to make sure I obeyed the requirements that would fire the OnCollision methods and OnTrigger methods appropriately. This took some time to organize while I went back and forth between documentation and experimenting in Unity. Eventually, it all worked out and the Enemy is now able to "see" the player within a certain range and chase after them. As well as, "see" orbs within a range and go and collect them.

It was quite interesting to watch how the AI state machine plotted its path in Scene view while the game was running.

Leave a comment

Log in with itch.io to leave a comment.