Building a behavior tree is very similar to building a decision tree, except for the addition of selectors and sequence node types.
We can start creating a behavior tree using a similarly wrapped function that instantiates a behavior tree and creates the first selector node for the tree:
function SoldierLogic_BehaviorTree(userData) local tree = BehaviorTree.new(userData); local node; local child; node = CreateSelector(); tree:SetNode(node); return tree; end
To add the first action, which is death, we add the required sequence, condition, and action nodes. As the ...