mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2026-01-06 07:50:22 +01:00
This clears out some errors that happen on every load of this demo in Godot 4 onward. It also makes the fonts actually work, as they did not before. We probably don't strictly **need** these font settings for a demo, but they were here before. I don't think `SourceCodePro-Black.ttf` was ever used, based on looking at history. So I removed it. Both `.tres` files are gone too, as those are not used in Godot 4. I have updated everything that used `SourceCodePro-Bold.ttf` to the new setup.
Hierarchical Finite State Machine
This example shows how to apply the State machine programming pattern in GDscript, including Hierarchical States, and a pushdown automaton.
Language: GDScript
Renderer: Compatibility
Check out this demo on the asset library: https://godotengine.org/asset-library/asset/516
Why use a state machine
States are common in games. You can use the pattern to:
-
Separate each behavior and transitions between behaviors, thus make scripts shorter and easier to manage.
-
Respect the Single Responsibility Principle. Each State object represents one action.
-
Improve your code's structure. Look at the scene tree and FileSystem tab: without looking at the code, you'll know what the Player can or cannot do.
You can read more about States in the excellent Game Programming Patterns ebook.
