AI attacking from cover
Using what I learned from the tutorial, I have started to build up a cover system for the AI. This is still a bit buggy but when the AI detects the player, it will now break away from its patrol path, find cover and move to a firing position to engage the player.
I used the first EQS quite similarly to how it was shown in the tutorial, I used a trace based query to find a position that cant be seen by the player. I then combined this with an overlap query to make sure the character will preferably be in contact with cover and a few distance queries to preferably be far from the player but close to the AI character
When the character is at the chosen location, I used some of the same events used by the player, to take cover and then ran a second, smaller scale query to find a shooting position. This time finding a position close to cover in line of sight to the player.
These behaviors are fired on a separate behavior tree to the patrol, which can be switched to when the player is spotted. The service used to select the tasks on the tree currently runs on AI tick, checking against bools for Cover and Player visibility. However I may need to change this up, as sometimes the AI will get stuck with its back to the player, unable to detect that it has been flanked.
Behavior tree progress
Progress video
Its pretty close to how I want it. When a player is spotted in the newer metal gear solid games, enemies would get startled and fire a few shots, run to cover and call for backup before engaging the player from cover. With a little more debugging I might actually get to that point soon.
For now, I have the patrolling and a response to getting spotted implemented so I will spend some time getting the cover behavior to a reasonable standard. When the player moves around it tends to cause it issues at the moment. Following that, I can move on to "caution" mode where enemies will search the area for the player.