Game Development Reference
In-Depth Information
• From
Intro
to
Player_Move
◦ Exit Time = 0.9 (Transition Duration = 2)
• From
Player_Move
to
Player_Attack
◦ PlayerReady = true (Transition Duration = 0)
• From
Player_Attack
to
Change_Control
◦ PlayerReady = false (Transition Duration = 2)
• From
Change_Control
to
Enemy_Attack
◦ Exit Time = 0.9 (Transition Duration = 2)
• From
Enemy_Attack
to
Player_Move
◦ BattleReady = true (Transition Duration = 2)
• From
Enemy_Attack
to
Battle_Result
◦ BattleReady = false (Transition Time = 2)
• From
Battle_Result
to
Battle_End
◦ Exit Time = 0.9 (Transition Time = 5)
Summing up, what we have built is a steady flow of battle, which can be summarized as
follows:
• The battle begins and we show a little intro clip to tell the player about the battle
• Once the player has control, we wait for them to finish their move
• We then perform the player's move and switch the control over to the Enemy AI
• If there are any enemies left, they get to attack the player (if they are not too
scared and have not run away)
• If the battle continues, we switch back to the player, otherwise we show the battle
result
• We show the result for 5 seconds (or until the player hits a key), then finish the
battle and return the player to the world together with whatever loot and experien-
ce they have gained
This is just a simple flow, which can be extended as much as you want, and as we contin-
ue, you will see all the points where you could expand it.
With our animator state machine created, we now just need to attach it to our battle man-
ager so it will be available when the battle runs; follow the ensuing steps to do this:
1. Open up the
Battle
scene.
2. Select the
BattleManager
game object in the project hierarchy and add an
An-
imator
component to it.
3. Now drag the
BattleStateMachine
animator controller we just created into the
Controller
property of the
Animator
component.