Need Help with AI Movement Mechanics (Urgent)

I was creating Ranged Enemy Mechanics with blueprints. The mechanics i implemented was if dist. btw player & enemy is under 500m it does a line trace in all 360 direction while storing each elements value as 1 degree. After that I created an array to add if the trace results for all 360 is true or false.

After that i stored data using for each loop to get current empty space and Max Empty Space. After getting max empty space i want to get the last index and first index of it. So that I can use the value to determine the direction where the ai should roll or dash.

For that i need to divide first index and last index /2 and get that index no. and set the direction to dodge and roll using that direction.

So, I need help getting it implemented the code is correct till getting the value of max empty and current empty space. But I need help getting the value of first and last index and getting the direction.

I am a artist by background and don’t know to code. So, even Ithough I know the logic I am getting confused while implementing.

Also, Can you check if the code I implemented is correct or not also i have a question while using for each loop loop body i am getting the max index space in 10 thousands while if i use completed i get the value correct. Why is that so i cant find the reason.

I don’t see anything on this image.
In the second loop you go straight to completed - meaning it will just check the last array element(maybe not even that).
The first loops completed should connect to second loop.
The add (both) should be disconnected form the second loop.
This approach seems very costly. Could cause stuttering.

Enemy movement behavior seems to be a rather complicated topic. At least at first…I imagine in time you figure it out to the point you add small nuances with randoms and give it an organic and natural fluidity.