Features
- Design StateMachine in a flowchart-like editor
- Visualize the flow of StateMachine & inspect parameters in realtime
- Visualize game/UI state from the 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 outcomes based on the input
- Compact data structure for StateMachine resource file
Installation
- Get gd-YAFSM either from the Github Repo or the Godot Asset Library
- Copy/paste it in the project’s addons folder
- Enable it from the plugins tab
Usage
Scene
- Add a StateMachinePlayer node
- Select the newly created node and find the new window for editing the state machine
- Click “Create StateMachine”
- Right-click on the graph and add a new entry state
- You can add your own states after the entry
- Use Shift-Drag to create connections
Code
After setting up the StateMachine node, you can connect with it via code.
There are 2 signals that the StateMachinePlayer triggers:
- transited(from, to)
- updated(state, delta)
You can set the state machine’s properties using set_param or set_trigger commands.
License
MIT
Extra
Quick’n Simple Tank AI in Godot
Do you want to learn how to create a State Machine Tank in Godot?
Get this free course and find out how to use gd-YAFSM to implement a patrolling tank that also attacks targets.
Get the free course from here.
