Game Development Reference
In-Depth Information
Creating a behavior tree agent
To use our behavior tree, we can replace the finite state machine and perform the same up-
date loop on our behavior tree instead. Regardless, if our agent is using a decision tree,
state machine, or behavior tree, its actions will be nearly identical, as the logic is merely
translated from one decision structure to another:
IndirectSoldierAgent.lua :
local soldier;
local soldierController;
local soldierBT;
local soldierUserData;
function Agent_Initialize(agent)
...
soldierBT = SoldierLogic_BehaviorTree(
soldierUserData);
end
function Agent_Update(agent, deltaTimeInMillis)
if (soldierUserData.alive) then
soldierBT:Update(deltaTimeInMillis);
end
soldierController:Update(agent, deltaTimeInMillis);
end
Search WWH ::




Custom Search