Game Development Reference
In-Depth Information
The die action
Creating a basic death action is very similar to our idle action. In this case, as death in our
animation controller is a terminating state, all we need to do is request that the DIE com-
mand be immediately executed. From this point, our die action is complete, and it's the re-
sponsibility of a higher-level system to stop any additional processing of logic behavior.
Typically, our agents will request this state when their health drops to zero. In the special
case that our agent dies due to falling, the soldier's animation controller will manage the
correct animation playback and set the soldier's health to zero:
SoldierActions.lua :
function SoldierActions_DieCleanUp(userData)
-- No cleanup is required for death.
end
function SoldierActions_DieInitialize(userData)
-- Issue a die command and immediately terminate.
userData.controller:ImmediateCommand(
userData.agent,
SoldierController.Commands.DIE);
return Action.Status.TERMINATED;
end
function SoldierActions_DieUpdate(deltaTimeInMillis,
userData)
return Action.Status.TERMINATED;
end
Creating a wrapper function to instantiate a death action is identical to our idle action:
SoldierLogic.lua :
local function DieAction(userData)
return Action.new(
"die",
SoldierActions_DieInitialize,
Search WWH ::




Custom Search