AI Patrol move backward

Hello,

This is for 2d Paper, maybe it’s for 3d Sidescroller too.

I used a simple AI Patrol with Behaviour Tree, but the problem is that the moment the AI spot the Player through the Sensor Sight (In AI Controller) and when the AI doesn’t detect my Player, it goes to the backward path point (Target Point Location) instead of going to the forward path point.

I mean, my game has 2 path point, one from the left and one from the right.

1.-If the AI sees me when i’m in the left side and when i leave its sensor sight (If i left from the left side), the AI will go to the right side (Backward) instead of going to the left side (Forward).

2.-And vice versa, if the AI sees me from the right side and when i leave its sensor sight from the right side, the AI will go to the left side instead of the right side.

3.-If the AI sees me from any side, lets say from the left side and when i leave its sensor sight from the right side (Since the AI has 90’ angle and of course, the AI will turn its body towards me), then the AI will go to the left side, where it spotted me.

My BT is too simple (From the UE4 Basic AI Tutorial, since i still doesn’t a lot how to do with the Key things).

The problem is, what should i do to make the AI go forward instead of backward? Because the AI will go to the opposite side from where i leave its sensor sight and i don’t know what is the problem.

I want to make it go from path 1 to path 2, even if i interrupted it with the sensor sight, i want the AI still going in an order of path 1 to path 2 then to path 1 and path 2, instead of going to the opposite side…

The AI sensor sight task (FindEnemy) doesn’t has nothing, it’s empty, i left it so it can stop moving when it sees me.

Thanks for the answer, i appreciate it since i don’t even know what is the problem behind it, so i think, it will take me a lot of day to resolve it alone (Maybe forever… since i want to use BT instead of BP that i find it quite easy than BT).

PD: the AI patrol does work fine when the AI doesn’t spot me, it goes path 1 to path 2 and vice versa.

I resolved it, well, i had the idea yesterday but since you can’t cast an actor in others actors, ai controller, character, i thought it was useless. (I tried it with a print text and look likes it doesn’t flow past the actor’s box thing).

But i find out today that you can cast an actor in a Behaviour Tree’s Tasks to check a condition (Branch) and since it works just for 1 time because i put a collipsion to the actor and since the actor doesn’t know how to desactive-active the condition, i put a delay to desactive-active it.

And i only needed to copy the FindNextPoint and rename it to FindFirstPoint and FindSecondPoint (Each one with its own actor, path node).

Quite hard to explain but i already resolved it.