Enemy encounter AI
- Unreal Engine 4
- Solo Project
This project was my first experience with AI and an opportunity to learn something new. I learned how to script AI functionality, work with behavior trees and improve navmeshes. The goal was to create a basic encounter AI that can patrol, attack, and communicate with each other.
Besides AI, I learned how to work with animations and blend them together.
- Walking, running, shooting, shooting from a cover
- Point patrol system
- Noise investigation system
- Call out target system
- AI perception system
- Cover system
- Decision-making system
- Investigation system
- Communication system
- Walking, walking-shooting,walking-aiming
- Running, Crouching
- Reloading, reloading-walking, reloading-running, reloading-crouching
I used a built-in behavior tree system in Unreal Engine 4. There are two trees for patrolling/investigating and for an encounter. There are multiple functions for action(hide, attack, reload, etc.), and the desition making system helps identify what to do.
After an AI unit hears noise it starts to investigate and look for the player. I used “Report Noise Event” to send an indication of noise in a radius. AI blueprint has a perception module that can receive sounds.
Decision making system
I designed and implemented a system where every unit has levels of danger and aggression. The level of danger depends on the health. The level of aggression depends on the average level of health of the nearest units. There are four outcomes of this system: Shoot from a cover, Hide, Suppress and Flank the player.
I used dialogue chat to simulate communication between enemies. Every time an AI unit hears or sees the player, or has to reload a weapon, it sends a message to the chat that is displayed to the player.
I used a built-in navigation mesh to generate a walkable area and calculate AI path.
I created a system that automatically separates all AI units into teams and adjusts patrol points between them. The points have settings for team number, member position, and queue number. After setting up points, an AI unit walks between the points in a loop. In case there are no patrol points, an AI picks a random point in a radius.
The cover system uses an algorithm to create cover points in a certain radius near the player. After points are generated, it filters them and picks the most optimal distance to the player, and checks if there are no enemies or objects. I used EQS to filter the points.
First, I implemented and set up animation for the player and then moved them to the enemy blueprint. There are walking/running, crouching, and reloading animation for normal view and for ironsight. The hardest part was to blend them together and make a smooth transition between them. I used skeleton blending for combining different animations together, but it created a problem if you change on animation, it does not send the time of the neighbor animation. I fixed it by writing a hotfix with an animation timer and sent it to the neighbor animation.