gd-YAFSM(Finite State Machine)

An asset by imjp94
The page banner background of a mountain and forest
gd-YAFSM(Finite State Machine) thumbnail image
gd-YAFSM(Finite State Machine) thumbnail image
gd-YAFSM(Finite State Machine) thumbnail image
gd-YAFSM(Finite State Machine) thumbnail image
gd-YAFSM(Finite State Machine) hero image

Quick Information

0 ratings
gd-YAFSM(Finite State Machine) icon image
imjp94
gd-YAFSM(Finite State Machine)

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

Supported Engine Version
4.0
Version String
0.6.2
License Version
MIT
Support Level
community
Modified Date
9 months ago
Git URL
Issue URL

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 README StackPlayer icon

    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) README StateMachinePlayer icon

    Manage state based on StateMachine and parameters inputted

    • state_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

Reference

  • StateDirectory

    Convert state path to directory object for traversal, mainly used for nested state

Resource

Relationship between all Resources 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, accessing StackPlayer/StateMachinePlayer alone should be sufficient.

  • State

    Resource that represent a state

    • name
  • StateMachine(extends State) README StateMachine icon

    StateMachine is also a State, but mainly used as container of States and Transitionss

    • states
    • 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

0 ratings

Your Rating

Headline must be at least 3 characters but not more than 50
Review must be at least 5 characters but not more than 500
Please sign in to add a review

Quick Information

0 ratings
gd-YAFSM(Finite State Machine) icon image
imjp94
gd-YAFSM(Finite State Machine)

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

Supported Engine Version
4.0
Version String
0.6.2
License Version
MIT
Support Level
community
Modified Date
9 months ago
Git URL
Issue URL

Open Source

Released under the AGPLv3 license

Plug and Play

Browse assets directly from Godot

Community Driven

Created by developers for developers