AI "Under fire" function is not working

Hello,

In UE5 I want to make a feature when I shoot near enemy, he takes cover. I already have “Take cover” feature in behavior tree.

So I implemented function that takes Vectors from line trace by channel (for shooting) in BP_Player.

The function (in BP_Enemy Base) then works in a way that it takes the closest point on line near AI and if its under 200, Player facing the target (dot in bp) and there is no wall between AI and Player (another line trace by channel) then adds 1 to variable “TimesUnderFire”.

Here are few problems:

  1. I dont know how to make “For all actors” and “Each loop” only in one BP (probably in BP_Enemy_Base)
  2. Second line trace by channel is not working, when shooting through walls it counts
  3. The variable “TimesUnderFire” has same amount on every child of BP_Enemy_Base, which is incorrect

Im kinda new to UE5, can somebody tell me how do I fix these issues please?