godot-simple-state
Godot Simple State is a clean and easy-to-use Finite State Machine (FSM) plugin for Godot 3.x. It simplifies state management by using nodes and provides functionalities like state transitions, signal handling, and dependency injection.
https://github.com/tavurth/godot-simple-statePreview Images




Godot Simple State: A Finite State Machine for Godot 3.x
Godot Simple State is a plugin that provides a clean and easy-to-use Finite State Machine (FSM) for Godot 3.x. It is designed to simplify state management in Godot games by leveraging the node-based architecture.
Key Features
- Node-Based State Management: States are implemented as child nodes of a StateMachine node, making them easy to organize and manage.
-
Simple State Transitions: The
$StateMachine.goto("state")
method allows for easy state transitions at runtime. -
State Functionality: The plugin provides virtual functions like
_state_enter
and_state_exit
for executing code when entering or exiting a state. It supportsawait
calls to ensure proper synchronization. -
Dependency Injection: The plugin automatically injects dependencies like
Host
(character controller) andStates
(StateMachine) into the state nodes. - Signal Handling: Signals connected to the StateMachine node are automatically forwarded to the current active state.
Usage
To use the plugin, install and enable it. Add a StateMachine
node to your character and create states by adding nodes as children to the StateMachine
. Attach scripts to these nodes to define state-specific behavior. The example project showcases transitions between "idle" and "attack" states every 3 seconds.