Game Development Reference
In-Depth Information
The pursue action
Previously, pursuit was using enemy calculations that were performed in the enemy evalu-
ator. With a knowledge source now providing these calculations, the pursuit action merely
fetches the enemy blackboard attribute to determine the best agent to be attacked:
SoldierActions.lua :
function SoldierActions_PursueInitialize(userData)
local sandbox = userData.agent:GetSandbox();
local enemy = userData.blackboard:Get("enemy");
local endPoint = enemy:GetPosition();
local path = Sandbox.FindPath(
sandbox,
"default",
userData.agent:GetPosition(),
endPoint);
...
end
function SoldierActions_PursueUpdate(deltaTimeInMillis,
userData)
if (Agent.GetHealth(userData.agent) <= 0) then
return Action.Status.TERMINATED;
end
local sandbox = userData.agent:GetSandbox();
local enemy = userData.blackboard:Get("enemy");
local endPoint = enemy:GetPosition();
local path = Sandbox.FindPath(
sandbox,
"default",
userData.agent:GetPosition(),
endPoint);
Search WWH ::




Custom Search