Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: fbeyrouti on September 05, 2013, 03:22:54 PM

Title: Why are variables local to an action kept after an FSM exists a state?
Post by: fbeyrouti on September 05, 2013, 03:22:54 PM
Hi,

We noticed that the values of action variables are kept after exiting the state that was running the action. Therefore, we the state is re-entered again the action variables do not have their "initial" values. This is somewhat unintuitive because conceptually a state (and by extension state actions) "exists" only when it is active.

A workaround would be to reset all these variables OnExit but is there a better way?

Title: Re: Why are variables local to an action kept after an FSM exists a state?
Post by: Alex Chouls on September 05, 2013, 08:26:13 PM
Conceptually variables are scoped to the FSM. Quite often you need to loop through a state multiple times to perform complex operations, so it's convenient for variables to keep their state.

If you're writing your own actions and you want them to reset, you would have to do that in OnExit.