โ† All examples

godot components

Finite state machine with child-node states

Run one active state at a time from child nodes, with ordered exit and enter calls, an optional transition table, queued requests and a bounded history. Use it for characters, menus, doors and game flow.

What this component contains

  • ATTRIBUTION.md
  • LICENSE
  • README.md
  • baltor_test.gd
  • component.json
  • example.tscn
  • finite_state_machine.gd
  • inspect_gdscript.py
  • run_tests.gd
  • test_package.py
  • tests/test_finite_state_machine.gd
  • verification/native.json

How it works

Class
BaltorStateMachine, extends Node
Methods
start(data: Dictionary = {}) -> bool; stop() -> void; transition_to(state_name: StringName, data: Dictionary = {}) -> bool; go_back(data: Dictionary = {}) -> bool; has_state(state_name: StringName) -> bool; get_state_node(state_name: StringName) -> Node; get_current_state() -> StringName; get_state_names() -> PackedStringArray; and 2 more
Signals
state_changed, transition_refused
Exports
initial_state, auto_start, allowed_transitions, history_size
Placement
res://baltor/godot_components/finite_state_machine/

Recorded checks

godot 4.7.2.stable.official.ed1daf0bf

  • godot_parse_check_only
  • godot_gdscript_tests
  • godot_tests_reject_gutted_component
  • godot_editor_import
  • godot_contract_reflection
  • godot_example_scene
  • godot_readme_usage_compiles

Limits to consider

One active state; no parallel or nested states (see the hierarchical state machine). States are found by node name among direct children. Queued requests are checked when they are applied, not when they are made. Input reaches the active state through _unhandled_input only. Verified with Godot 4.7.2 headless; written against the Godot 4.3 API.