I want to create AI for patrolling enemies.
I need the enemies to move left and right. If they spot the player within 500, I want them to stop moving left and right, start moving towards the player and start shooting. If the player moves away (>550). I need them to go back to the same place and continue the patrol.
So far, I've tried two ways but both are buggy and don't work.
1. I put Pathfind and Line of Sight and 8-Direction behaviour. Used a variable for the two different behaviours of AI(patrolling, attacking)
2. Used the bullet behaviour.
I've attached a screenshot for both ways.
I'll have a lot of guards in my game so I would like, if its possible to do it without changing every time the coords for every guard.