Game Development Reference
In-Depth Information
Can shoot enemy evaluator
To determine if our agent can shoot an enemy agent, we can perform a distance check to
see whether our agent is within 3.0 meters of the enemy. While this might produce some
false positives, it's effective enough to allow our agents to shoot one another with a relat-
ively high accuracy:
SoldierEvaluators.lua :
function SoldierEvaluators_CanShootAgent(userData)
if (userData.enemy ~= nil and
Agent.GetHealth(userData.enemy) > 0 and
Vector.Distance(
userData.agent:GetPosition(),
userData.enemy:GetPosition()) < 3) then
return true;
end;
return false;
end
Search WWH ::




Custom Search