Game Development Reference
In-Depth Information
position, Agent.GetPosition(agent));
if (closestEnemy == nil or
distanceToAgent < distanceToEnemy) then
local path = Sandbox.FindPath(
sandbox,
"default",
position,
agent:GetPosition());
if (#path ~= 0) then
closestEnemy = agent;
distanceToEnemy = distanceToAgent;
end
end
end
end
end
return { confidence = 1, evaluation = closestEnemy };
end
As we've created a completely new way of selecting enemies, we can swap the knowledge
source within our agent's blackboard in order to provide easy A/B testing on the new be-
havioral selection:
IndirectSoldierAgent.lua :
function Agent_Initialize(agent)
...
soldierUserData.blackboard:AddSource(
"enemy",
KnowledgeSource.new(
SoldierKnowledge_ChooseBestVisibleEnemy));
...
Search WWH ::




Custom Search