Install Asset
Install via Godot
To maintain one source of truth, Godot Asset Library is just a mirror of the old asset library so you can download directly on Godot via the integrated asset library browser
Quick Information
Designer-friendly Finite State Machine implemented in "Godotic" wayThis version is only compatible with Godot 4.x, check out godot3(https://github.com/imjp94/gd-YAFSM/tree/godot3) branch for older version- Design StateMachine in a flowchart-like editor- Visualize flow of StateMachine & inspect parameters in realtime- Visualize game/UI state from flowchart- Similar workflow as using AnimationTree, and not required to inherit any custom class, just plug and play- Nested Finite State Machine workflow supported to create complex state machine with ease- As a Resource, StateMachine can be used repeatedly in different scenarios(StateMachinePlayer) and provide different outcome based on the input.- Compact data structure for StateMachine resource filev0.6.2:Fixes StateMachineEditor is_instance_valid check on reconnection Fix StateDirectory.get_current_end() doesn't work as expectedFix FlowChartGrid draw_multiline_colors errorFix StateDirectory.get_current_end() and StateMachinePlayer.path_end_dir(Remove some super._init() for godot 4.1.3v0.6.1:Fix _on_update params error, flowchart grid and popup menusv0.6.0:Port to Godot 4.0v0.5.2:Support sorting transitions.Fix "entered" signal is not emitted and trigger is flushed when StateMachinePlayer started.v0.5.1:Fix condition label in graph not removed as deleted from inspector.Fix output flooded with null exception, when stopping scene in remote debug and when switching between local/remote StateMachinePlayer node.v0.5.0:Support remote debug, simply select any StateMachinePlayer node in remote scene tree to view flow of StateMachine in realtime.Fix StateMachinePlayer's nested triggers are not flushed and some UI bugs.v0.4.1:Fix possible to connect to self when reconnecting, validate StateMachine Resource everytime loaded in editor, and minor improve on UI.v0.4.0:gd-YAFSM now support nested FSM workflow in 0.4.0 & fixed various annoying UI bugsCheck out CHANGELOG(https://github.com/imjp94/gd-YAFSM/blob/master/CHANGELOG.md) for more details*Always backup project files before update
Documentation
Classes
All of the class are located in res://addons/imjp94.yafsm/src
but you can just preload res://addons/imjp94.yafsm/YAFSM.gd
to import all class available:
const YAFSM = preload("res://addons/imjp94.yafsm/YAFSM.gd")
const StackPlayer = YAFSM.StackPlayer
const StateMachinePlayer = YAFSM.StateMachinePlayer
const StateMachine = YAFSM.StateMachine
const State = YAFSM.State
Node
- StackPlayer
Manage stack of item, use push/pop function to set current item on top of stack
current # Current item on top of stack
stack
- signals:
pushed(to) # When item pushed to stack
popped(from) # When item popped from stack
- StateMachinePlayer(extends StackPlayer)
Manage state based on
StateMachine
and parameters inputtedstate_machine # StateMachine being played
active # Activeness of player
autostart # Automatically enter Entry state on ready if true
process_mode # ProcessMode of player
- signals:
transited(from, to) # Transition of state
entered(to) # Entry of state machine(including nested), empty string equals to root
exited(from) # Exit of state machine(including nested, empty string equals to root
updated(state, delta) # Time to update(based on process_mode), up to user to handle any logic, for example, update movement of KinematicBody
Control
- StackPlayerDebugger
Visualize stack of parent StackPlayer on screen
Reference
- StateDirectory
Convert state path to directory object for traversal, mainly used for nested state
Resource
Relationship between all Resource
s can be best represented as below:
var state_machine = state_machine_player.state_machine
var state = state_machine.states[state_name] # keyed by state name
var transition = state_machine.transitions[from][to] # keyed by state name transition from/to
var condition = transition.conditions[condition_name] # keyed by condition name
For normal usage, you really don't have to access any
Resource
during runtime as they only store static data that describe the state machine, accessingStackPlayer
/StateMachinePlayer
alone should be sufficient.
- State
Resource that represent a state
name
- StateMachine(
extends State
)StateMachine
is also aState
, but mainly used as container ofState
s andTransitions
sstates
transitions
- Transition
Describing connection from one state to another, all conditions must be fulfilled to transit to next state
from
to
conditions
- Condition
Empty condition with just a name, treated as trigger
name
- ValueCondition(
extends Condition
)Condition with value, fulfilled by comparing values based on comparation
comparation
value
- BooleanCondition(
extends ValueCondition
) - IntegerCondition(
extends ValueCondition
) - FloatCondition(
extends ValueCondition
) - StringCondition(
extends ValueCondition
)
Designer-friendly Finite State Machine implemented in "Godotic" way
This version is only compatible with Godot 4.x, check out godot3(https://github.com/imjp94/gd-YAFSM/tree/godot3) branch for older version
- Design StateMachine in a flowchart-like editor
- Visualize flow of StateMachine & inspect parameters in realtime
- Visualize game/UI state from flowchart
- Similar workflow as using AnimationTree, and not required to inherit any custom class, just plug and play
- Nested Finite State Machine workflow supported to create complex state machine with ease
- As a Resource, StateMachine can be used repeatedly in different scenarios(StateMachinePlayer) and provide different outcome based on the input.
- Compact data structure for StateMachine resource file
v0.6.2:
Fixes StateMachineEditor is_instance_valid check on reconnection
Fix StateDirectory.get_current_end() doesn't work as expected
Fix FlowChartGrid draw_multiline_colors error
Fix StateDirectory.get_current_end() and StateMachinePlayer.path_end_dir(
Remove some super._init() for godot 4.1.3
v0.6.1:
Fix _on_update params error, flowchart grid and popup menus
v0.6.0:
Port to Godot 4.0
v0.5.2:
Support sorting transitions.
Fix "entered" signal is not emitted and trigger is flushed when StateMachinePlayer started.
v0.5.1:
Fix condition label in graph not removed as deleted from inspector.
Fix output flooded with null exception, when stopping scene in remote debug and when switching between local/remote StateMachinePlayer node.
v0.5.0:
Support remote debug, simply select any StateMachinePlayer node in remote scene tree to view flow of StateMachine in realtime.
Fix StateMachinePlayer's nested triggers are not flushed and some UI bugs.
v0.4.1:
Fix possible to connect to self when reconnecting, validate StateMachine Resource everytime loaded in editor, and minor improve on UI.
v0.4.0:
gd-YAFSM now support nested FSM workflow in 0.4.0 & fixed various annoying UI bugs
Check out CHANGELOG(https://github.com/imjp94/gd-YAFSM/blob/master/CHANGELOG.md) for more details
*Always backup project files before update
Reviews
Quick Information
Designer-friendly Finite State Machine implemented in "Godotic" wayThis version is only compatible with Godot 4.x, check out godot3(https://github.com/imjp94/gd-YAFSM/tree/godot3) branch for older version- Design StateMachine in a flowchart-like editor- Visualize flow of StateMachine & inspect parameters in realtime- Visualize game/UI state from flowchart- Similar workflow as using AnimationTree, and not required to inherit any custom class, just plug and play- Nested Finite State Machine workflow supported to create complex state machine with ease- As a Resource, StateMachine can be used repeatedly in different scenarios(StateMachinePlayer) and provide different outcome based on the input.- Compact data structure for StateMachine resource filev0.6.2:Fixes StateMachineEditor is_instance_valid check on reconnection Fix StateDirectory.get_current_end() doesn't work as expectedFix FlowChartGrid draw_multiline_colors errorFix StateDirectory.get_current_end() and StateMachinePlayer.path_end_dir(Remove some super._init() for godot 4.1.3v0.6.1:Fix _on_update params error, flowchart grid and popup menusv0.6.0:Port to Godot 4.0v0.5.2:Support sorting transitions.Fix "entered" signal is not emitted and trigger is flushed when StateMachinePlayer started.v0.5.1:Fix condition label in graph not removed as deleted from inspector.Fix output flooded with null exception, when stopping scene in remote debug and when switching between local/remote StateMachinePlayer node.v0.5.0:Support remote debug, simply select any StateMachinePlayer node in remote scene tree to view flow of StateMachine in realtime.Fix StateMachinePlayer's nested triggers are not flushed and some UI bugs.v0.4.1:Fix possible to connect to self when reconnecting, validate StateMachine Resource everytime loaded in editor, and minor improve on UI.v0.4.0:gd-YAFSM now support nested FSM workflow in 0.4.0 & fixed various annoying UI bugsCheck out CHANGELOG(https://github.com/imjp94/gd-YAFSM/blob/master/CHANGELOG.md) for more details*Always backup project files before update