Player state
In Garden 2 any action the player takes is supposed to feel meaningful and have consequences. This means certain actions lock the player character into an animation until it has finished playing. For example, a sword swing has to be finished until any other action can be taken.
Initially, this was done by using boolean variables "IsAbleToAct", "IsMovementLocked", "IsJumping" etc. However, the code started to get cluttered when the action required several of these booleans to be checked before the action could be performed. Actions also had to set certain booleans to true at the beginning and back to false at the end of the action. It works, but is messy and it's easy to miss a boolean which creates extra work for later on. In the picture below are the booleans that had to be checked to allow movement.
![]() |
| Input event for moving, a few booleans have to meet conditions for the player to be able to move. |
To make it simpler, I created a list of player states as enumeration and used those states to determine which actions the player is able to take. This allows, in most cases, just one check when performing actions, and it's easy to set restrictions. The higher in the list the state is, the more restrictive it is. Currently list consists of (from lowest to highest): FreeToAct, Attacking, PerformingAction, and Hurt states.
FreeToAct allows the player to perform any action. Attacking restricts from taking any action other than attacking, so the player is able to continue attack combos. PerformingAction includes any action aside from moving and attacking, locking the player to finish the action before the state changes back to FreeToAct. Hurt state happens when the player takes damage, and it cancels and restricts any action until the hurt animation has finished playing.
![]() |
| Event for moving after implementing the states via enumeration, It's much cleaner. |
There is one thing to keep in mind when developing the system further. When doing a combo attack the player is already locked to do the next attack of a combo when the input is given during the first attack, meaning the player cannot use dodge action in case they notice an incoming attack that they would want to dodge instead of continuing the combo. So an action should be able to overwrite the rest of a combo.

