This is the 24th episode of the unreal engine advanced locomotion series. But still, you can apply this method to find covers using the environment query system in any project. Here, an environment query will generate a grid around the player character to find out the locations which don't have a line of sight from the player so that the player can't shoot them if NPCs move into one of such locations. Then NPC will consider the distance to each location from the player and from the NPC character and go to the ideal covering position. While moving to the cover, the NPC AI character will shoot at the player. After moving into a cover, the AI characters will stop shooting and again run to another location that has a line of sight from the player so they can shoot the player again. For this, another environment query will be used. After implementing this AI behavior, the AI enemies will have a more dynamic behavior when they are in a fight.
CodeLikeMe Third-Person shooter series: https://www.youtube.com/playlist?list=PLKLABJGyKV-CmWAXXeuUTer0iI0kSG1W4
.
project files
https://www.patreon.com/posts/63654325