Hello everyone,
Here’s a short tutorial I made demonstrating a way to create a finite state machine.
The power of my solution comes from the use of concurrency. Repeating methods that take more than one frame are started when your transition to a new state. Interruptions of tasks are dealt with by using Prime[31]'s coroutine manager (an excellent tool for any Unity developer I would say). This would be hard and ugly to implement in the Update (trust me I’ve tried!)
Transitions between states are dealt with using delegates and lambda functions to avoid code bloat.
Hope you like the tutorial. If you want the script let me know!
Cheers,
Tom