What do you think about this code for AI free roam and follow player?

So, my game is 3d maze with AI enemy which chase player.

And here is my BP code for this, it works very fine to me, but any suggestion to make it simpler?

Begin play - it sets and save random player position in “Random Location” variable, and then goes to “Random location move” custom function.

“Random location move” function moves AI to that random location variable, and when “Ai move to” is “On Sucess” - it sets a new “random location” variable, and it loops again and again…

Event tick - there is branch that inspect is AI pawn sensing activate.

If false - nothing happens, AI moves again it random locations.
If true - he follow player (saw player variable is activated"

Here is something interested - if AiMoveTo is “OnFail” (it means that OnFail is pin that is activated when AiMoveTo process is on running) then it set new variable “Last Actor Location”
So every time when AI see player-it sets player position every frame.

Then I have delay of 4 second and then it set new variable “LastActor Location+1sek”, which is player location after some time (here is 4 second, variable have a wrong name :smiley: )

So this is for AI when pawn sensing is activated - it follow player and save player position var + player position after 4 second.

OnSeePawn - when is activated, there is delay od 0,5 second and sets “saw player” variale to false (sequence is just for some testing).
Because “Event tick” check that variable, that means that every 0,5 second pawn sensing is deactivated. (basicaly :smiley: )

So in that time if saw player is positive, AI follow player, but when in that time (0,5 sec) AI loose sight of player - he will go to “Last Actor location”,and then moves again to “Last Actor Location + 1 sek” - I mean player position+4 second in this example.

This delay of 4 second is very interesting because he will tell to AI to go to good path, because when AI go to that last position, sometime he will turn 180 and goes to oposite direction, which is stupid.
Here I can make maybe another 1-2 variable with player position in delay.

And when finally AI goes to last location, and player is not on sight - he will triger Random Location Move function and again goes arround maze.

I’m sorry about language.

What do you think of that code? I tested in and works good for me.