Super Simple State Machine for Unity
I'd like to share my super-simple easy-to-use State Machine for Unity. I haven't talked much about it, but I've been chipping away at it and it's turning it a really awesome Library that's getting a fair bit of organic search traction - which tells me I'm on to something.
It's based around the idea that State Machines are super useful pattern in Game Development, but they shouldn't be tedious to use. To that end my library uses Reflection (in much the same way Unity does for all your monobehaviour scripts) to make the State Machine really straightforward to implement. I'm sharing because I think it can be of great benefit to both beginners and pros, and I'm curious to find more murky edge cases. ;)
More details over on the Github repo:
https://github.com/thefuntastic/Unity3d-Finite-State-Machine
It's based around the idea that State Machines are super useful pattern in Game Development, but they shouldn't be tedious to use. To that end my library uses Reflection (in much the same way Unity does for all your monobehaviour scripts) to make the State Machine really straightforward to implement. I'm sharing because I think it can be of great benefit to both beginners and pros, and I'm curious to find more murky edge cases. ;)
More details over on the Github repo:
https://github.com/thefuntastic/Unity3d-Finite-State-Machine
Comments
This is quite similar to the QCF state machine that I wrote. Our one is similar, but the state machine is an instantiated object rather than a base class. I often have a single component that references more than one state machine, so I prefer that approach. I'm also always averse to introducing third party code into my inheritance hierarchy :P
In case someone else finds comparisons interesting, here is ours: http://pastebin.com/Y6q9JKSM. It does not have the reflective magic, and like @Squidcor 's version is not a MonoBehviour. One interesting feature is that it support nested machines (although quite trivially). I also pasted our push-down automaton, which is another trivial (but useful) extension.