Creating Behavior Tree

Moving onto Behavior Trees, let's begin to construct our first tree! In this project, we will create AI that resembles the behavior of a neighborhood dog. It will change its behavior state randomly every so often and continue to search for any mailman, who may loiter by its dog pin.

This will touch on using Environment Query System (EQS), which is still an experimental but powerful feature in Unreal Engine 4. It will be responsible for handing the dog a new position to search for the mailman in. So, if you're ready, let's open up a new Third Person project.

Let's create a few things for our dog to route between. The following are the steps to do so:

  1. First, let's make a new custom Target Point class and name it Foodbowl.
  2. Next, let's make a new custom Target Point class and name it DogHouse:
    Creating Behavior Tree
  3. Place these two actors accordingly within the world. We will use these to reference our dog where to move to when in the appropriate state. So, basically, we will use Target Points or waypoints to reference the vector location of this actor within the blueprints later on.
  4. Now, we need a new Enumeration class called DogState; this will hold our current state of the dog. This value is important for executing the correct tree for the appropriate responses we send to the AI, such as detecting the nearby mailman.
  5. The DogState class will have Hungry, Barking, and Idle as the three available states. Hungry will be responsible for telling the dog to navigate to the dog bowl to eat food. The Barking state will tell the dog to search for the mailman. The Idle state will tell the dog to go to its dog house. At any time, the dog will begin to chase the mailman if he gets too close:
    Creating Behavior Tree
..................Content has been hidden....................

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