Finite State Machine Helper is a highly robust yet lightweight C# framework to implement state machines in your project. It supports both simple state machines as well as very complex multi-level nested states.
Basic features
- Use your own classes with Enter(), Exit() and Update() functions for states. Develop state machines like a professional, no more silly enums and switch cases!
- Just call a single line of code to transition to another state, the framework will automatically Exit() the current state and Enter() the next state.
Advanced features
- Nested states within states! Rather than just a single layer of states, your states could have states within them as well, with unlimited depth. For eg, your character has an Alive and Dead state, and the Alive State is broken down further into Walking and Swimming states.
- AND vs OR states. If a state has children, specifying it as an OR state means that only one child state is active at any time. Specifying it as an AND state means all children states are active. Very useful for running monitors/managers in parallel!
- Passing parameters during transitions. When your character transitions from Idle to Combat state, you can send the enemy character's GameObject (or any parameters) inside the transition, and this will automatically call the Combat state's constructor that matches those parameters.
- Broadcast messages to all active states in the state machine. This is useful if you have a complex multi-level state tree and need to transition a state from within a different state, or you want multiple states to transition with one line of code.
- Override the state machine class with your own class! This way you can have your own member variables accessible to any active state in the state machine, regardless of its depth.
- Easy debugging! Watching the state machine object in the debugger will allow you to expand the entire tree of currently active states. You can also print the current tree to the log anytime by iterating through the tree.
- Define your statemachine structure with simple, easy-to-read syntax. No need to struggle with GUI tools.
Quickstart Example
(A full example scene with all advanced features can be found inside the download)
Message Broadcast Example
AND state Example
Transition with Parameters Example