The EnemyAI game object has its own Player.cs script, as we saw earlier, but it also has the script we're most interested in: the EnemyBehaviorTree.cs component. This component contains the BT for our enemy agent, along with some helper functionality. Let's take a look at that code now:
using UnityEngine;using System.Collections;using System.Collections.Generic;public class EnemyBehaviorTree : MonoBehaviour { private Player playerData; private Player ownData; public RandomBinaryNode buffCheckRandomNode; public ActionNode buffCheckNode; public ActionNode healthCheckNode; public ActionNode attackCheckNode; public Sequence buffCheckSequence; public Selector rootNode;
We start off with some declarations as usual. Most ...