Week 9 - Space Patrol (AI)

Space Patrol (AI)

Our main goal this week is to integrate the game functions together, and I also put my AlienAI into our unified Project. The rest of the week, I'm adding functionality to the AI portion of our game, which is Space Patrol.

Compared with last time, my progress is faster. However, the implementation method of Space Patrol is different from ordinary pathfinding AI. NavMesh in Unreal can only be used for 2D planes and some ramps that can be walked. And AI flying in the sky like Space Patrol cannot use NavMesh to achieve.

Therefore, the way I have researched is to apply velocity to a Static Mesh and cancel its gravity so that it can move in the air to achieve flight. And add a behavior tree to it so that it has a pathfinding function.

For this game Space Patrol, my design is like this. When it can't see the player's spaceship in its field of vision, it will patrol and slowly approach the player's spaceship, so as to avoid randomly patrolling the position and being too far away from the player. When the spaceship enters its field of view, it will accelerate to approach the spaceship, maintain a certain distance and attack the player's spaceship (there is no attack capability yet).

Implement Explanation

1. Doing the same thing as we are creating AI, and also two of the behavior tree task that we need to use. Also, this time I am utilizing the AI perception that I researched before. (Referring to what I did for the AI perception week post). And further, we have to obtain some information on what AI had percept, then update a boolean value and a vector location of the player's spaceship to our decorator which is mentioned in step 2.

2. For the space patrol's behavior tree, I also utilized the decorator that I learned from last week. This time its function is to check if the player's spaceship is in its field of vision. (If yes, that branch of behavior can be run by the behavior tree which is approaching the player's spaceship)

3. Next is to create some tasks for our behavior tree to run with. This time we got two tasks, both of them implemented with similar ideas. Which is giving the static mesh a velocity and then calculated the world location between the space patrol and the player's spaceship. Finally, add some offset so that it can maintain a certain distance from the player's spaceship.

4. Finally, to make the space patrol more realistic. I make it could also look at the player when it is in the 1000 range in Unreal, so when it moves it will not face some weird direction.

Demo


Some Reference I used

AI Perception

https://www.youtube.com/watch?v=JBFWxMdtMSU&list=PLNBX4kIrA68lJZIdFOpWqqY7d4ehjVKMx&index=3

Facing Player

https://www.youtube.com/watch?v=JkvswrXyBcA



Comments