Fixing Enemy AI Aiming - Kelsey 11/29/2023


The enemy AI was currently set up with an arrow projectile that had a set aim rotation that was used to determine the location of where the enemy projectiles would shoot when the enemy attacks. With this functionality the enemy AI would shoot the base perfectly but not the player. It was realized after setting up our flying map. This map has the mechanics of allowing the player to equip a jet pack and flying around the map. When the  player is flying around the enemy AI they wouldn't aim correctly at the player. With this bug found we realized that the enemy AI never truly aimed at the player unless they were right in front of the enemy AI. Below I have the original mechanics of how the spawn actor uses the arrow projectile for all attack calls.

In order to fix this I needed to make the arrow projectile aim correctly when attack the player. The functionality (shown below) was to get the player's and the enemy's location and find the look at rotation. After interpolating this worked correctly when the enemy was attacking the player, but with this new functionality it would miss the base when not shooting the enemy and instead stayed in the rotation of the enemy. To fix this I used the same Boolean that is used when calling the attack on the player. In the sphere collider we have for attacking the player there is a Boolean called CanAttackPlayer. This Boolean was used in the attack function that way if it is false the arrow projectile rotation doesn't change and goes back to its original values, but if it is true then the arrow projectile on the enemy AI will aim correctly.


Get MystiMayhem

Leave a comment

Log in with itch.io to leave a comment.