9. Behavior Tree Setup

Since you already have all the assets necessary to fill out the tree, you're going to be building this Behavior Tree:

Before we get into the steps to create this Behavior Tree, let's talk about what it does (or rather what it will do once we create the necessary EQS bits).

  • We enter the graph at the top Sequence Node, and then start executing it's children from left to right, and will keep executing as long as its children are successful.

  • First is the EQS Query node that runs the FindPlayer template. We only allow this node to execute once every 0.5 seconds, and if it fails, the tree is locked out of executing the other nodes by the Cooldown Node returning failed, thusly failing its parent sequence node.

  • But, if the EQS Query is successful (it finds the player), then the second EQS Query is allowed to execute, finding the AI a place to hide.

  • Finally we move to the place that the second EQS Query found.

Steps

  1. Double-click the RunnerBT Blueprint in the Content Browser to open it for editing.

  2. Add a Sequence Node (right-click in the Graph Area Composites Sequence)

  3. Connect the Root Node to this new Sequence Node

  4. Create a Run EQS Query Node (right-click in the Graph Area Tasks Run EQSQuery)

  5. Connect it to the Sequence Node

  6. Select this Run EQS Query Node, and in the Details panel, set the Query Template to FindPlayer

  7. While still in the Details panel set the Blackboard Key to ActorToFleeFrom

  8. Add a Cooldown Decorator to the Run EQS Query Node (right-click the Run EQS Query Node Add Decorator... Cooldown)

  9. Select the Cooldown Decorator and set its Cool Down Time to 0.5

  10. Create another Run EQS Query Node (right-click in the Graph Area Tasks Run EQSQuery)

  11. Select the second Run EQS Query Node, and in the Details panel, set the Query Template to FindHidingSpot

  12. Again, while still in the Details panel, set the Blackboard Key to FleeToLocation

  13. Position it to the right of the first Run EQS Query Node

  14. Create a Move To Node (right-click in the Graph Area Tasks Move To)

  15. Connect it to the Sequence Node

  16. Select the Move To node and set Blackboard Key to FleeToLocation

  17. While still in the Details Panel, set Acceptable Radius to 0.5

  18. Position it to the right of the second Run EQS Query Node

With everything connected the Behavior Tree will is ready and no further edits to it will be necessary.