Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: ciabaros on April 13, 2013, 01:27:10 PM

Title: How to "Reset" a Finished FSM
Post by: ciabaros on April 13, 2013, 01:27:10 PM
Problem Setup:

Without enabling the "Reset on Disable" feature, I need to manually restart this FSM (via code, from another FSM). I tried PlayMakerFSM.Reset( ) and Fsm.Reset( <component> ), and both just reset the FSM structure itself (by clearing the component's data), to the default 1-state FSM.

I Tried:

Of course, I'm explicitly enabling it first.. all works if the "Reset on Disable" flag is enabled on this FSM component, but I need to do the same action that this flag initiates in the backend, in my custom Action code.. Help :)
Title: Re: How to "Reset" a Finished FSM
Post by: Alex Chouls on April 13, 2013, 02:11:10 PM
Not at my computer to check, but try Fsm.Start();
Title: Re: How to "Reset" a Finished FSM
Post by: ciabaros on April 13, 2013, 02:17:27 PM
Sorry I didn't explicitly mention, I was running Start( ) in every case. But I have since found a workaround:

It feels like some weird technicality, but it works!

It seems that the way you programatically "Reset" an FSM which does not "Reset on Disable", AND is Finished via FinishFSM ([fsmComponent].Fsm.Finished==true), is to:

That was fun. Hope this saves anyone the hours it took me to figure out by trial and error.

Edit:
Only Fsm.Stop( ) cares about the RestartOnEnable flag. So enable can happen after the flag is reverted, and hence, the entire sure-resetting mechanism is just: