Problems with Enemy Detection
Reported By: David Tarnowski
September 15, 2023
THE PROBLEM
This week I ran into issues with the enemy AI detection that caused problems for gameplay and the user experience. The enemies were not properly detecting and engaging the player character, even when standing still right in front of them. Instead, they would endlessly walk in circles without initiating their attack behaviors. This also caused the AI to rapidly flip between their "pre-combat" and "in-combat" states nonstop, which further impeded the enemy AI.
From a gameplay perspective, the enemies were not providing any challenge or threat to the user since they failed to ever attack. It also hurt immersion as the AI behavior was unrealistic. I needed to address this promptly as enemy detection and response ties directly into our core combat loop which is essential to keeping players engaged.
THE SOLUTION
The root cause of the erratic enemy movement and detection issues was that the scripts were referencing the wrong game object's rotation when calculating directional facing and movement. I had originally used the rotation of the game object that the script was attached to, rather than the enemy model itself. To fix this, I changed the scripts to instead reference the actual enemy character's transform rotation when determining which way to move and look. This ensured they were properly rotating and moving based on their own orientation rather than that of the logic game object. Additionally, I added logic in the pursue state to halt movement once within attack range and sight of the player.
Before, they would endlessly walk in circles around the player while in pursuit. By stopping movement on detecting the player, it forces the enemy to pause and initiate attack actions, rather than nonsensically passing by them. These fixes resulted in more realistic enemy behavior and consistent transitions into combat once the player is detected.
Get Psyche
Psyche
Welcome to your next great souls-like adventure!
Status | In development |
Author | Sad Ogre Studios |
Genre | Role Playing, Adventure |
Tags | Atmospheric, Fantasy, Indie, mind-bending, psyche, Sci-fi, Singleplayer, Souls-like, Third Person |
More posts
- Problem: Harder Isn't Always More FunDec 14, 2023
- How to make the controller feel more responsiveDec 14, 2023
- ModelMayhem: A Programmer's TaleDec 08, 2023
- Problem: Face Your FearsDec 03, 2023
- Time to show our real main characterDec 01, 2023
- Problems: melee combat system is too boringNov 24, 2023
- Problem: Frames Win Games?Nov 17, 2023
- Problem with camera transitionNov 16, 2023
- Combo Attack systemNov 11, 2023
- Problems with code reusabilityNov 03, 2023
Leave a comment
Log in with itch.io to leave a comment.