Hi, I’m making an Action Tower Defense game, and I have some issues with making my AI movement be not that robotic.
What I mean by that is that by default the AI tends to use the most optimal path for it, making every turn as sharp as possible, moving not in the center of a path, but diagonally or along a wall, depending on the destination point. That doesn’t look natural at all.
I want the AI movement be natural, making the AI turn the corners smoothly and move in the center (or something like that) of the path.
To explain a little bit better, I made a simple painting. The first one is the robotic movement, and the second one is the one I want to achieve, or similar to that.
There is something to consider as well:
-
There is a main objective an AI has to reach – a crystal(s); the AI has to reach only the closest one. The crystals are placed on different places on the map.
-
There are towers and players as well, which can temporary change the objective of an AI, i.e. make the AI walk towards one of them.
-
If the AI will be agroed far enough and then left alone, (i.e. there are no towers and players to agro at) the AI has to pick up a new crystal to walk towards – the one that is the closest to its current position.
Initially I thought about making some path system that contains different paths that consist just of a set of point vectors manually set by a level designer. An AI would have a custom path following component (it doesn’t have anything to do with the UE-made one) which would get the path it has to follow on spawn. The AI wouldn’t move just to the objective, but to each individual point specified by the path. If the AI would be distracted by some entity, then it would use the default path finding algorithm. After it would be left alone, it would try to find the closest point on the path it followed before.
I didn’t like the actual implementation, it looked too boilerplate, thus I didn’t carry on developing the idea.
Another idea that I have found by searching on the Internet are the splines, but at the first glance I didn’t find them useful in a such dynamic environment.
So my question is: How can I make an AI move in a way described above following all the described possible path deviations?
Thanks for reading.