Game Development Reference
In-Depth Information
Throttling agent visibility updates
As we've throttled how often sight events are sent out to teammates, we should also throttle
how often our agent will cast rays into the environment, as raycasts can quickly become ex-
pensive. All that's required to update our agent's visibility is to determine the last update
time and see whether at least half a second has gone by in order to determine whether the
visibility should be updated:
AgentSenses.lua :
local lastUpdate = 0;
function AgentSenses_UpdateSenses(
sandbox, userData, deltaTimeInMillis)
local updateInterval = 500;
lastUpdate = lastUpdate + deltaTimeInMillis;
if (lastUpdate > updateInterval) then
UpdateVisibility(userData);
lastUpdate = lastUpdate % updateInterval;
end
end
Search WWH ::




Custom Search