1# Hierarchical Finite State Machine
2
3This example shows how to apply the State machine programming
4pattern in GDscript, including Hierarchical States, and a
5pushdown automaton.
6
7Language: GDScript
8
9Renderer: GLES 2
10
11## Why use a state machine
12
13States are common in games. You can use the pattern to:
14
151. Separate each behavior and transitions between behaviors,
16   thus make scripts shorter and easier to manage.
17
182. Respect the Single Responsibility Principle.
19   Each State object represents one action.
20
213. Improve your code's structure. Look at the scene tree and
22   FileSystem tab: without looking at the code, you'll know
23   what the Player can or cannot do.
24
25You can read more about States in the excellent
26[Game Programming Patterns ebook](https://gameprogrammingpatterns.com/state.html).
27
28## Screenshots
29
30![Screenshot](screenshots/fsm-attack.png)
31