The OnExit event will be fired in that case. I just realized that the active state is always exited and re-entered even in the case the snapshot state is the same. I don’t know if that’s good… what do you think?
I’m thinking it would be bad in a situation where a player reloads mid-game and is currently in some state…in that case, I wouldn’t want an OnExit to fire when the saved-game state is restored, I’d just want the snapshot to be restored without any side effects. But maybe there are situations where it would be good? One solution to my situation would be to stop all FSMs when loading a save…don’t remember if that’s possible or convenient atm.
[Edit] Oh, and exit/re-enter when restoring the same state…hmm, not sure about that. I think I can imagine scenarios where either one would be helpful. Maybe making it an option on the restore function would be good?
After thinking about it some more, the current behavior may be fine…should spend some time actually trying to use it before making suggestions for changes
I just released version 1.7 with a new feature “Submachine State with History”. See the release post here. In this version I also fixed the exit/re-enter issue I reported earlier. In the end I decided that if the state is already correct, it should not be exited.
Awesome! Thanks for implementing this!
By the way, I just submitted the v1.7 update for Unreal 4.23. Should be online in a couple of days.
Hello,
I was wondering if its possible to defer Events from the main FSM to a submachine FSM?
I’m not sure I understand the question. Could you please give an example of what are you trying to achieve, please?
I would like events from the top FSM to be deferred to the bottom sub FSM
when triggering the event “Was Set” in the main loop the events correctly get deferred to the TestDeferred_Main State
I’m sorry for being dense, but I’m still struggling to make sense of your question. I asked you to explain what are you trying to achieve, rather than asking about the solution your are trying to apply, because I want to rule out the XY Problem, but you didn’t give me the information I expected. I’ll try to answer anyway. When the MainLogic FSM is in state SubTest and receives Damage events, these are “deferred”: this means they are recorded, as opposed to being handled or discarded. When the WasSet event is received, this is what is happening:
- State SubTest is exited. As part of the exit, the FSM_SubTest sub-FSM is forcibly terminated
- A transition is made to state TestDeferred_Main
- Upon entering TestDeferred_Main, all the recorded (“deferred”) events are re-triggered in the new state, which has the opportunity to handle/discard/defer them. In your case, they are handled
As the deferred events are re-triggered in step 3, this mean you can’t re-trigger those events in the Idle state of the FSM_SubTest sub-FSM, since that sub-FSM was terminated in step 1!
Please notice that, while you are in the SubTest state, any Damage event triggered with the flag “Trigger in sub-states” will be triggered in both MainLogic and FSM_SubTest. In that case, each of the two FSMs can handle or defer the event as necessary. If you want to defer those events so that they are deferred in the sub-FSM, you need to have a state **in the sub-FSM **that defers them.
no problem, thanks for your prompt responses. I think I understand the logic a bit better now and I think I just have a design flaw. (played around with it at 3am :))
I wanted to defer the FSM Event Damage which is triggered by On Hit (of the actor) even when the substate is not active. But that does not really make sense …
I will rethink the logic, but will probably come back with a different/more thorough question at a later point
Any update on the 4.24 release?
Any chance I can grab a Dev/RC version from a drop?
I’m going to work on it tomororrow. Hopefully, it should be available early next week.
FIY, I have just submitted the 1.7.1 release of GC FSM, targetting UE 4.24. It also includes a bugfix for a memory leak reported by @Ghar on Slack. It is now under review from Epic and, if all goes well, should hopefully be available to everyone early next week. Stay tuned!
Finally! It took longer than I expected, but now a version targeting UE 4.24 is available on the Marketplace. Enjoy!
Hi, I was wondering about the Get FSM Active State node with submachines. I have a test actor with this state setup:
On BeginPlay, it launches the ParentFSM only. If I use GetFSMActiveState with the FSM set to ParentFSM, it correctly returns the submachine state.
If I set it to SubFSM, it returns No State. Also, if I use IsFSMRunning to see if SubFSM is running, it returns false, even though I know it is running (because the “Test State” prints a message OnEnter).
Is there any way to get a reference to the active state in a submachine when the submachine is running? Do I need to do something special with the Context pin of the GetFSMActiveState or IsFSMRunning nodes to make that happen?
Thank you very much for reporting this issue. It seems that GetFSMActiveState returns only the FSMs that are launched by the specified object. However, while SubFSM runs in the same context object as ParentFSM, it is actually launched by the ParentFSM itself. This is necessary so that ParentFSM can properly stop SubFSM when SuperState1 is exited. However, this prevents GetFSMActiveState from finding SubFSM as you would expect. It seems that I did not approach this use case properly. Unfortunately, there is currently no way to retrieve the SubFSM instance in this scenario. I am currently working on a fix. Please stay tuned.
Update: I just submitted a fix. Please allow a few days for Epic to approve the change.
Wow that was fast. Thanks!
That’s what happens when you get a detailed report, with a clear reprorule. I should thank you.
By the way… I just receieved a mail from Epic saying the fix is already online! Please let me know if you spot anything else. Enjoy!