Enemy Defense Mechancis - Kelsey 10/13/2023


The team wanted to set up a defense mechanic for the player laying down a barrier to protect the base from enemies. For this to work the enemies had to be stopped and attack the barriers before continuing to the bases. The first implementation of this was to set up a check in the player attack collider to see if the enemy was close to the barrier and then to have the AI Move TO function go towards the barrier. When setting up the NPC attack functionality this worked perfectly. When trying to do the same with the barriers the enemies walked right past the barrier and continued to head towards the base. (Shown in picture above)

After trying out a couple of different things the solutions were to use while loops in two different places. There’s a while loop int eh begin play function that checks if the barrier is valid and to head towards the barrier, then there’s a check for the while loop that is if the barrier still has health to continue to head towards the barrier The other while loops in the component end overlap for the player attack collider. This while loop is the same but also includes the attack function for the enemy. The while loop being in the component end overlap ensures that the enemy still heads for the barrier even if they try to walk out of distance. On the component begin overlap it just heads to the barrier and attacks. For this to work we also needed to add a Boolean to enable and disable barrier attacks and base following.

Get MystiMayhem

Leave a comment

Log in with itch.io to leave a comment.