Enemy AI Improvements


Author: Gabriel Alvarez

Issue-

Previously, I added an enemy AI that would patrol an area, search for a player, run towards them and attack them. While the enemy AI worked, it did not do a great job at what it was supposed to do. Due to this, some improvements had to be made to the enemy AI.


Fixes-

While I maintained the same basic functionality of the enemy AI, a lot of the code had to be changed. The enemy still uses Root motion in order to blend its animations with its movement, but the way it knows where to move was completely changed. Furthermore, their animations were also fixed and some of the major bugs, such as rapidly spinning in place or patrolling to an area that they could not move to were also changed. Finally, since the enemy AI base was finally functional, I decided to start making the AI for another one for another one of the enemies. This enemy is called a Seeker, which unlike the regular enemy does not target the player when the player enters their field of vision, instead it will target the player if it "hears" them. To simulate the player's sound, the player emits a sphere whenever they move. This sphere is based on their velocity and if the sphere enters the enemy's hearing radius, the enemy will target the player until the player exits the hearing radius for some period of time.


Added/Updated items below-

  • Enemy AI
    • Attack State
      • Controls what the enemy will do once they get close enough to attack the player. The enemy will deal damage to the player if their collider actually collides with the player's collider instead of dealing damage whenever they play the attack animation.
    • Pursue State
      • Controls what the enemy will do once they see the player.
      • The Enemy will stop pursuing the player if they exit their line of sight.
    • Patrol State
      • Controls what the enemy will do once they exit their idle state and start roaming around their designated area. The enemy will no longer get stuck trying to go to areas that they cannot reach.


  • Seeker AI
    • Attack State
      • Same as the Enemy AI
    • Pursue State
      • Same as the Enemy AI.
      • The Seeker will stop pursuing the player if they exit their hearing radius for a period of time.
    • Patrol State
      • Same as the Enemy AI.
    • Idle State
      • Same as the Enemy AI.

Later updates will add -

  • More types of enemies.
  • More attacks for each type of enemy.
  • The Seeker will have a melee and ranged attack based on their distance from the player.

Files

731 installer + level 1.zip 30 MB
Mar 24, 2023

Get 731

Leave a comment

Log in with itch.io to leave a comment.