The most unique and important part of a turn-based battle system is the turns. Controlling the turns is incredibly important and we will need something to handle the logic behind the actual turns for us. We'll accomplish this by creating a battle state machine.
Starting back in our BattleScene
, we need to create a state machine using all of Mecanim's handy features. Although we will still only be using a fraction of the functionality with the RPG sample, I advise you to investigate and read more about its capabilities.
Navigate to the Assets\Animation\Controllers
folder and create a new Animator Controller called BattleStateMachine
, then we can begin putting together the battle state machine. The following screenshot shows you the states, transitions, and properties that we will need:
As shown in the preceding screenshot, we have created eight states to control the flow of a battle with two Boolean parameters to control its transition...