Now that we've implemented both approaches to animation control, it's time to create both of these agent types within the obstacle course. As there's no actual agent decision-making logic, we'll be binding each different state to a keyboard hotkey so that we can influence what actions the agents perform. Here, we can see a few agents running the obstacle course:
As all the animation control for our direct control agents exists within the agent Lua script, all that remains is setting the soldier's state based on hotkeys. Note that as we have no direct change state, we handle this completely within the hotkey itself:
DirectSoldierAgent.lua
:
local function _IsNumKey(key, numKey) -- Match both numpad keys and numeric keys. return string.find( key, string.format("^[numpad_]*%d_key$", numKey)); end function Agent_HandleEvent(agent, event) if (event.source == "keyboard" and event.pressed) then -- Ignore new state...