playMaker

Author Topic: Why are variables local to an action kept after an FSM exists a state?  (Read 1842 times)

fbeyrouti

  • Playmaker Newbie
  • *
  • Posts: 9
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?


Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4002
  • Official Playmaker Support
    • LinkedIn
Re: Why are variables local to an action kept after an FSM exists a state?
« Reply #1 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.