Inspiaaa/UnityHFSM
A fast, tried-and-tested hierarchical finite state machine library for Unity, designed to be easy to use yet powerful without compromising performance.
📋 Changes
- Dynamic Logic Control: You are no longer "locked in" after setup. Core properties — including `needsExitTime`, `forceInstantly`, `isGhostState`, and `isExitTransition` — can now be modified at runtime, allowing your states to adapt their behaviour on the fly.
- Action Introspection: The new `HasAction` method lets you check if the current active state hierarchy has defined an action for the specified trigger. This is perfect for implementing "fallback" logic (like a "click" sound when an ability is unavailable) without cluttered logic.
- Enhanced Stability: We've addressed an import crash for Unity 6 users and further optimised the `StateMachine` class to ensure your game remains as performant as possible.
In a time of ever-increasing RAM prices, you’ll be delighted to hear that we’ve **fixed a critical memory leak** in the new Animator Graph visualisation feature. Additionally, we've resolved a synchronisation issue that could trigger internal consistency errors in the Unity Editor. Special thanks to @sandsalamand for the contribution.
🐛 🛠️ Animator Graph Visualisation Tool: Clearer Insights, Better Debugging
- 
📦 🧹 Polishing the Details
- This release also focuses on making UnityHFSM cleaner and more reliable:
- Internal refactoring to make the codebase easier to maintain and to extend.
- Improved naming of classes and interfaces to make development even more straightforward.
- A collection of small features, bug fixes, and improved documentation straight in your IDE.
⚡ ⚡ Performance Boosts: Smoother and Faster
- Performance is a top priority, and this release brings some significant speed improvements:
- Direct transitions are 20% faster when the source state needs exit time.
- Delayed transitions are now up to 60% faster.
- ---
- For more information on this release and on the latest compatibility-breaking changes, please see the [changelog](https://github.com/Inspiaaa/UnityHFSM/blob/master/Changelog.md).
- ---
- With UnityHFSM v2.2, the library is more powerful, efficient, and user-friendly than ever. Thanks for using UnityHFSM, and I look forward to seeing what you build with it! 🙌
Version 2.1 of UnityHFSM adds exciting new features, while once again improving performance. With the new `ParallelStates` class, you can effortlessly run multiple sub-states / state machines in parallel. At the same time, the new `StateChanged` event and the `rememberLastState` feature make (hierarchical) state machines more powerful and flexible to your use cases than ever before. If you're working with complex, large state machines, these are up to 15% faster now thanks to general optimisations. Bugs have been fixed, naming improved, and new documentation has been written. For more information on the latest changes, please see the [changelog](https://github.com/Inspiaaa/UnityHFSM/blob/master/Changelog.md).
This release fixes the sample code which did not compile after the recent 2.0.0 release. It also reintroduces the `timer` field in the `CoState` class which was lost in the previous release. If you are migrating from a pre-2.0 version, please see the [changelog](https://github.com/Inspiaaa/UnityHFSM/blob/master/Changelog.md), as the 2.0 release includes compatibility-breaking changes.
Version 2.0.0 comes with exciting new features such as **ghost states**, **transition callbacks** and **exit transitions**. Exit transitions finally provide an easy and powerful way to define the exit conditions for nested state machines, essentially levelling up the mechanics behind **hierarchical state machines**. At the same time, **debugging** complex hierarchical state machines has never been easier thanks to the new `GetActiveHierarchyPath()` method. In addition, the latest release comes with **many improvements** to existing features, such as the support for coroutines, the `canExit` mechanics, and the `HybridStateMachine` class, while also fixing numerous bugs related to delayed transitions. Thanks to refactorings, the internal code is easier to read and maintain. Please see the [changelog](https://github.com/Inspiaaa/UnityHFSM/blob/master/Changelog.md) when migrating to the latest version, as it includes compatibility-breaking changes.
Version 1.9.0 of UnityHFSM introduces the **action system** which allows you to define custom events (like `OnLogic`) that can call functions in the active states. This release also adds "**two way transitions**" which can greatly reduce the amount of boilerplate code required in many cases. Furthermore **performance** has been increased when using value types as the state names (e.g. `State<int>`). 👍 Read more: [Changelog](https://github.com/Inspiaaa/UnityHFSM/blob/master/Changelog.md)
Version 1.8 of UnityHFSM adds support for generics. Now the datatype of state identifiers / names and the type of event names can be easily changed. Thanks to the new "shortcut methods", state machines can be written with less boilerplate than ever and certain cases, such as empty states, can be optimised automatically for you. 👍 1.8 also adds support for installation via Unity's package manager UPM. Read more: [Changelog](https://github.com/Inspiaaa/UnityHFSM/blob/master/Changelog.md)
:sparkles: 1.7.2 let's you activate triggers that can propagate down the hierarchy to the active sub-states. :+1:
✨ Version 1.7 introduces Trigger Transitions which let you effortlessly leverage the efficiency of event-based transitions, in combination with the full power of the existing high-level transition types. 👍 The error messages have been greatly improved in 1.7.1, so that they are concise and helpful.
