Let's look at this example (which we will later implement in Unity). Imagine a patrolling robot that shoots anything that gets near it, but works only during the daytime. A possible BT for this kind of agent is shown in the following diagram:
Let's run this BT, assuming that the target is close and it is not night:
- The first node is a Repeat decorator; it does nothing but cycle the BTs, so we can ignore it for now.
- The selector starts executing its first child; we go down to the left.
- We are now at the first Sequence node; again, we execute the first node. IsNight? returns Failure (because it is not night!). ...