Aaron Franke f28a09ea0d Fix bullets in the Finite State Machine demo il y a 3 ans
..
debug 7e129db12e Use "not" instead of the exclamation mark in GDScript files il y a 3 ans
fonts 5b744fa1e6 Add HFSM + pushdown automaton demo il y a 6 ans
player f28a09ea0d Fix bullets in the Finite State Machine demo il y a 3 ans
screenshots fcc7d5c723 Optimize PNG images using oxipng il y a 4 ans
state_machine 006309bd6f Many tweaks thanks to IAmActuallyCthulhu il y a 4 ans
Demo.tscn f28a09ea0d Fix bullets in the Finite State Machine demo il y a 3 ans
README.md d4bf89d364 Link to the asset library from the README of each demo il y a 4 ans
icon.png fcc7d5c723 Optimize PNG images using oxipng il y a 4 ans
icon.png.import a45b84a5ad Handle multiple resolutions in most demos il y a 5 ans
project.godot 814909538f Update projects to Godot 3.3 il y a 3 ans

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: GLES 2

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:

  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