I was able to program an AI, using sight perception, to run away from the player by using the vector direction between both locations of the ai and the player character. The issue I’m running into is that when the ai runs into a wall, it has no other place to go to, because its next location would be beyond that wall.
(The pic below shows the overall running away mechanic, it turns the vector between the player and the ai into a direction vector, which then is applied to the ai’s world location by a magnitude of 200 units. This makes it so that the ai always runs away from the player depending on where the ai is in respect to the player)
I tried to implement a TraceSphereByChannel to check if there is an obstructing object (a wall) in front of the ai. Then I was able to tell it to take a sharp 90 degrees turn whenever it detects a wall in front of it.
(here I created a vector generator that finds a random vector that is 90 degrees from the original direction of where the ai is running. I had that vector be the new vector the ai would run towards)
After all of that, the problem ended up being that the ai ends up zigzagging along the wall as its destination shifts consecutively from running into the wall to running at 90 degrees from its original direction.
So I am kinda lost at this point, because with the system that I have implemented, I dont know how to tell the ai to keep running away from the player but to also avoid running into walls. Maybe there is a better ‘run away’ blueprint that would make it easier to fix this issue? Otherwise, if anyone can help me find a solution using what I’ve made so far, I would be very grateful !