Danil Alexeev c492e5fd73 Update some GDScript files for Godot 4.3 (#1129) 3 месяцев назад
..
debug bac1e69164 Use static typing in all demos (#1063) 8 месяцев назад
fonts 5553ecfd88 Fix font code for Godot 4 in Finite State Machine (#1027) 10 месяцев назад
player c492e5fd73 Update some GDScript files for Godot 4.3 (#1129) 3 месяцев назад
screenshots fcc7d5c723 Optimize PNG images using oxipng 4 лет назад
state_machine c492e5fd73 Update some GDScript files for Godot 4.3 (#1129) 3 месяцев назад
Demo.tscn 5553ecfd88 Fix font code for Godot 4 in Finite State Machine (#1027) 10 месяцев назад
README.md b4c73f4888 Fix README links to asset library (#1078) 7 месяцев назад
icon.webp 63d1cd9a60 Use 128×128 WebP icons for all demos (#885) 1 год назад
icon.webp.import 63d1cd9a60 Use 128×128 WebP icons for all demos (#885) 1 год назад
project.godot bac1e69164 Use static typing in all demos (#1063) 8 месяцев назад

README.md

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/2714

Why use a state machine

States are common in games. You can use the pattern to:

  1. Separate each behavior and transitions between behaviors, thus make scripts shorter and easier to manage.

  2. Respect the Single Responsibility Principle. Each State object represents one action.

  3. 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.

Screenshots

Screenshot