Enemy AI Mechanics – Kelsey 09/20/2023


As a team we wanted the enemy AI to target the base and the player. We wanted the enemy to when spawned head for the base and attack the base to take it down. We also wanted that when the player is near to head for and attack the player. There were many problems trying to implement this. The enemy would only sometimes head for the base, the enemy wouldn’t acknowledge the player’s presence, and the enemy would only attack the player if they were close to the base.

The solution to this was to use Booleans, collision spheres, and on component begin overlap functions. As a default we had the enemy as soon as they were spawned head to the base. The way we did this was by making a sphere collider that was large enough to always have a built base within it. On the component begin overlap for this collider we had a function that had the AI move to the base. We then had a smaller collider that would allow the AI to attack the base, this would allow the AI to attack the base if close enough. For following the player, we started by implementing it the same way but realized we needed to set Booleans for base attacking and player attacking that way the AI would know to either or. After seeking the player, we also had to add a second attack call inside of the player attack collider so that the AI could attack the player even away from the base.

Get MystiMayhem

Leave a comment

Log in with itch.io to leave a comment.