Danil Alexeev c492e5fd73 Update some GDScript files for Godot 4.3 (#1129) | 3 miesięcy temu | |
---|---|---|
.. | ||
debug | 8 miesięcy temu | |
fonts | 10 miesięcy temu | |
player | 3 miesięcy temu | |
screenshots | 4 lat temu | |
state_machine | 3 miesięcy temu | |
Demo.tscn | 10 miesięcy temu | |
README.md | 7 miesięcy temu | |
icon.webp | 1 rok temu | |
icon.webp.import | 1 rok temu | |
project.godot | 8 miesięcy temu |
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/2714
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.