Game Development Reference
In-Depth Information
Continue behavior tree evaluation
Continuing evaluation of the behavior tree is required whenever an action is completed, as
the action's parentage could contain a sequence that the behavior tree must continue evalu-
ating. In order to continue every possible sequence, we can use the currently executing
node's parent to determine whether it's part of a sequence. We will continue moving
through parents until the root node is processed and only continue sequence evaluation if
one of the encountered parents is a sequence:
BehaviorTree.lua :
local function _ContinueEvaluation(self, node,
deltaTimeInMillis)
local parentNode = node:GetParent();
local childNode = node;
-- Navigates upward within the tree to find any
sequences that
-- require continued evaluation.
while (parentNode ~= nil) do
if (parentNode.type_ ==
BehaviorTreeNode.Type.SEQUENCE) then
-- Found a sequence, continue evaluating from
the
-- current executing node within the sequence.
local childIndex =
parentNode:ChildIndex(childNode);
-- So long as the executing child was not the
last
-- node within the sequence, evaluate the
sequence
-- starting on the next child node.
if (childIndex <
parentNode:GetNumberOfChildren()) then
return _EvaluateSequence(
Search WWH ::




Custom Search