Chapter 5. Giving AI Choices

In this chapter, you will learn how to introduce autonomous behavior into your characters using Behavior Tree. Behavior Tree is a methodology that allows you to view your AI logic visually. Behavior Tree is a type of hierarchical task network resulting in a state-oriented design. So, each state will dictate our current task instead of a goal.

This chapter will cover:

  • Behavior Tree
  • Blackboard
  • The components of Behavior Tree, including Selector, Decorator, Service, and so on
  • Building a Behavior Tree to run on a dog character

Behavior Tree in AIController

In this chapter, we will use Behavior Tree and scripts to create our autonomous state-oriented behavior. However, before we get to a higher-level control of our AI, let's understand some of the fundamental components of what allow us to control our AI. So, from the start, we have AIController, which is similar to PlayerController; this controller is responsible for interpreting all our AI input. This input is applied by the world when we request that it is moved.

With this in mind, we can introduce influence through multiple avenues within the code. We could tell AIController to move to a location, or we can tell AIController to run Behavior Tree. What's also very important to understand is that movement is applied with the CharacterMovement component. If you created a subclass from CharacterMovement, you can extend and continue to use the same Behavior Tree to introduce movement in theory.

One example of this is the car AI project I created for the Unreal Engine 4 development forums.

The link for the same is https://forums.unrealengine.com/showthread.php?25073-UPDATED-5-16-A-I-Templates-Bot-Car-amp-Flying-AI.

The internal movement component was responsible for taking the Move To request from the Behavior Tree. So, this allowed me to tell my car to go to certain locations, know when it was finished, and simply repeat the process. This is powerful if you're trying to create AI because a majority of what you need to do is move.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset