Implement the Nodes

After we have made a plan for our Behavior Tree, the next step is to check whether our BT implementation of choice (in our case, Behavior Bricks) already includes some of the nodes. Of course, we want to reuse as much pre-made nodes as possible. Reading the Behaviors Bricks documentation, we can see that it already includes nodes such as IsTargetClose, MoveToGameObject, Wander, and AlwaysTrue, plus, of course, Repeat and Selectors.

Therefore, we need to write all the rest. Let's look at a step-by-step process to do this:

  1. Let's start with Shoot. First, we create a simple Action called ShootOnce that just shoots a single bullet:
using Pada1.BBCore; using Pada1.BBCore.Tasks;using BBUnity.Actions; [Action("Chapter09/ShootOnce")] ...

Get Unity Artificial Intelligence Programming - Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.