-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there a StateChanged changed event for when any transition occurs, even a sub-machine one? #29
Comments
I see this PR is kind of implementing that: #23 I'd vouch for And for sub-machine states being reported on highest level, maybe an array signature could work: |
I think you can do this by having all your states inherit from a state that calls an event in OnEnter or OnExit. |
Hi @tomsseisums, Having such an event for debugging purposes sounds very useful and the idea to use it to separate game logic and UI code is especially intriguing. I have though about your proposed event signature The first problem is generics. Each nested state machine allows you to use a different type for the The second issue is performance. One of the main goals of UnityHFSM is to be extremely performant and to avoid GC allocations after initialisation. Having to allocate an array on each transition reduces the transition performance and increases the pressure on the garbage collector, potentially contributing to lag spikes. Although I can see where you are coming from with this signature, all things considered, I do not think that I am going to implement it in UnityHFSM. But this does not mean that you cannot do so in your own project. As UnityHFSM is open source, you could edit the code to better fit your exact use case. Alternatively, you could also write your own util code that uses the existing features of UnityHFSM to accommodate your use case. Generally speaking, I think that the |
Haven't found a way to listen to any transition happening.
Currently I have found I would like something like that for debugging, as I'm working with hierarchical machines.
But I also feel I could make use for something like that to build UI around State. As to keep the game logic in states and respective transitions, but UI being reactive on top of it, no matter what and how deep is going on.
The text was updated successfully, but these errors were encountered: