Game Development Reference
In-Depth Information
Initializing the controller
The initialization of the controller creates the ASMs responsible for animation handling of
the soldier mesh and weapon mesh. The important thing to note is that the soldier controller
places a command immediately into the queue so that the agent can be placed into an idle
state upon creation:
SoldierController.lua :
function SoldierController.Initialize(
self, agent, soldier, weapon)
self.asms["soldier"] =
Soldier_CreateSoldierStateMachine(soldier);
self.asms["weapon"] =
Soldier_CreateWeaponStateMachine(weapon);
-- Data that is passed into Soldier_Shoot, expects an
agent,
-- and soldier attribute.
local callbackData = {
agent = agent,
soldier = soldier
};
-- Add callbacks to shoot a bullet each time the
shooting
-- animation is played.
self.asms["soldier"]:AddStateCallback(
Soldier.SoldierStates.STAND_FIRE,
Soldier_Shoot,
callbackData );
self.asms["soldier"]:AddStateCallback(
Soldier.SoldierStates.CROUCH_FIRE,
Soldier_Shoot,
callbackData );
_soldierMesh = soldier;
Search WWH ::




Custom Search