Game Development Reference
In-Depth Information
Starting the battle
As it stands, the state machine is waiting at the Begin_Battle state for us to kick
things off. Obviously, we want to do this when we are ready and all the pieces on the
board are in place.
When the current Battle scene we added in Chapter 7 , Encountering Enemies and Run-
ning Away , starts, we load up the player and randomly spawn in a number of enemies into
the fray using a coroutine function called SpawnEnemies . So, only when all the nasty
goblins are ready and waiting to be chopped down do we want to kick things off.
To tell the state machine to start the battle, we simple add the following line just after the
end of the for loop in the SpawnEnemies IEnumerator coroutine function:
battleStateManager.SetBool("BattleReady", true);
Note
Do not ask me why we can affect the properties just by using their string names and can-
not do the same with the states; it just baffles me. I hope they change this in a future re-
lease.
Now when everything is in place, the battle will finally begin.
Search WWH ::




Custom Search