derkork / godot-statecharts

A state charts extension for Godot 4
MIT License
761 stars 39 forks source link

HistoryState doesn't work #11

Closed lavstudia closed 1 year ago

lavstudia commented 1 year ago

Please check HistoryState does not work, I added it as a child node to CompoundState, but when HistoryState transitions to history and _state_restore is not called

derkork commented 1 year ago

I cannot reproduce this, it seems to work fine in the history state demo. Could you give some more information about how you set this up or create a small example project that shows the problem?

lavstudia commented 1 year ago

Yes, sure. Here is a simple example illustrating the described problem test_fsm_history.zip

derkork commented 1 year ago

Ok the problem seems to be that I didn't describe the usage of the history state very well. If you want to return to what the history state has saved you need to transition to the history state itself, not to the parent compound state, e.g. in your example:

image

If you transition to the parent state it will just be a normal transition and no history will be restored.

https://user-images.githubusercontent.com/327257/235749588-3ae5bb07-164c-4146-9193-2a6f6d5359a9.mp4

I will update the documentation to give better instructions on how to use it.

lavstudia commented 1 year ago

Thanks a lot for the detailed explanation! Everything worked. Great addon! Good luck in development!