Week 5 - AI Path Finding

 AI Path Finding

In the game we make, our alien enemies need to go from the outside of the spaceship to the inside in order to defeat the player. So in a maze (internal structure of the spaceship), the alien needs to use AI pathing finding to complete this part of the project.

This week's research and development did not go as smoothly as expected. Unreal engine blueprints are more difficult to get familiar with than I imagined. Most of the time I don't know which node to connect to and achieve the effect I want. So it took me a lot of time to get familiar with this part, and so far I still don't quite understand the use of blueprints.

But with the help of some videos, I still managed to accomplish my goal for the week of an AI being able to move from point A to point B. To achieve this function, I used Nav Mesh in the Unreal engine to complete it.

From this point on, I also have my goals for the next week. So far, my AI will only calculate the travel route at the moment of starting the game, which is the Nav mesh calculated in advance by Unreal. If the structure of the maze changes while the game is in progress (the effect we want to achieve in our project), the AI will not change the route because of the change in the structure of the maze but will continue to follow the established route, even if it is a dead end.

At the moment, my idea is that I may need to optimize my AI's behavior tree more. However, I think it might not be that simple. I notice even that when I use Nav Mesh for pathfinding, even if I improve the behavior tree of the AI, the Nav Mesh does not seem to change during the game. That is, even if the AI ​​knows how to recalculate the destination at the moment route, it will still calculate it according to the original Nav Mesh.

I don't know of any other ways to help me continue to improve so far, and it may take some time to research this part.

The video that helps me finish: 
https://www.youtube.com/watch?v=JGXwWVyqrCU&list=PLNBX4kIrA68lJZIdFOpWqqY7d4ehjVKMx&index=1

Implement Explanation

1. First, I created a simple maze for the test purpose of this demo. And creating a NavMesh for the whole area of the maze by placing a NavMesh bounds volume to cover the whole maze. The green part shown is the Nav Mesh layout which is the part where the AI can walk.


2. For an AI, we would need to have four things two blueprints one with the character and another as an AI controller. Then we also need a behavior tree and a blackboard for this AI. The character blueprint is where we place what our AI looks like and reference our AI controller in pawn (in AI Controller Class).

3. In the AI controller blueprint, we need to set the AI to run the behavior tree when the game started.

4. In the behavior tree of AI, we need to indicate to our AI the tasks that need to be completed. The unreal engine has some common tasks, but most of the tasks need to be written by ourselves. Here, I wrote a simple task called GetToEnding, which is to help our AI get the coordinates of the endpoint so that it can calculate the route. When a task is completed, it will go to the next one, here is Move to. After reaching the endpoint we specify, it will wait. We used the Sequence above, so all tasks will be completed in order from left to right.

Note: I noticed that I would need to add the finished execute node at the back of the tasks so it could respond to the behavior tree that the completion of the task is successful or not. Otherwise, it just keeps sticking to the current task.

5. Finally, the use of a blackboard from my understanding is storing some value we need. So far, the only value we stored in it is the ending point location. which we need to write the value in the GetToEnding task and use in the MoveTo task.


Demo

The issue I face and try to solve next week




Comments