FPS Tower Defense Toolkit Basics: Enemy AI
The FPS Tower Defense Toolkit has 3 different types of enemy AI bots: Core Bomber, Melee & Ranged. They’re derived from the parent class ‘BP_EnemyAI_Parent’, which houses the core logic for all types of enemy bots. These include moving toward the power core, turning to face a target, handling damage receive events as well as update calls to wave handler when the bot is destroyed.
-
Core Bomber: The Core Bomber bot is a slow moving unit with a large pool of hit points. It does not possess any threat detection logic. Apart from moving toward the Core, it’s only other functionality is to self destruct to do massive damage to the Core, which is handled through the custom event ‘Event Attack Active Target’.
-
Melee: The Melee bot has an intermediate level of speed & hit points when compared to the Core Bomber & the Ranged bot. It’s ‘Vision Check’ function continuously searches for the player character & determines if it’s within range using a combination of distance, angular & line trace checks. Once within the range of the player, it will move on to attack the player. If the player leaves it’s vision range, it reverts to it’s original state & moves on to attack the Core
-
Ranged: The Ranged bot is a fast moving offensive unit with ranged attacks. It has low hit points compared to the other bots. Like the Melee bot, it uses a ‘Vision Check’ function to search & attack the player if it’s within range. In addition to that, the Ranged bot can also mark the player as a target, if the player keeps attacking it from directions that are not within it’s direct vision range. This feature is handled by the function ‘Detect Target When Attacked’.
The Enemy AI Bots use the default nav mesh based pathfinding to dynamically alter their paths at runtime based on the placement of tower based around the level. They do not use any sort of crowd movement or inter bot collisions, but instead use randomized approach vectors from the Enemy Spawn Point towards the Power Core. This makes sure that the bots do not always end following the exact same paths even if the general path direction remains the same & hence prevents crowding at the exact same point near the Power Core.