playMaker

Author Topic: Simulating Pre and Post Update of a state machine  (Read 2561 times)

fbeyrouti

  • Playmaker Newbie
  • *
  • Posts: 9
Simulating Pre and Post Update of a state machine
« on: September 23, 2013, 10:21:02 AM »
Hello,

I am trying to find a way to execute some code that mimics pre-update and post-update of a playmaker FSM. Basically I would like to run some code before running all state actions, and run some code after running all state actions. That would be true no matter which state I am in.

Is there a way to do that only in PlayMaker and without having to write extra pre-update and post-update monobehaviours?

Thanks,

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Simulating Pre and Post Update of a state machine
« Reply #1 on: September 24, 2013, 06:15:12 AM »
Hi,

 uhm... difficult.

Can you explain your use case?

bye,

 Jean

fbeyrouti

  • Playmaker Newbie
  • *
  • Posts: 9
Re: Simulating Pre and Post Update of a state machine
« Reply #2 on: September 24, 2013, 09:19:20 AM »
1. We want to clear a number of variables at the beginning of each state
2. We want to run the state machines
3. We want to treat these variables after running the fsm

Basically it is the equivalent of adding two actions in each state: one at the beginning and one at the end. The two actions are always the same no matter what the state is. But we do not want to do that if possible.

A hierarchical FSM would have done that pretty easily, but as far as I understand PlayMaker does not support that yet. Am I right? Is there any other way?

Thanks,

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Simulating Pre and Post Update of a state machine
« Reply #3 on: September 25, 2013, 01:52:56 AM »
Hi,

I had a similar issue with R.mote where I need to duplicate the Input class from unity, and the only way I could mimic the same behavior ( say you get a boolean flag true during one frame when the button is pressed), was to delay everything by one frame. but I was scripting all this, within playmaker I am not sure there is a convenient enough solution to be viable.

Do you have some programming knowledge?


Bye,

 Jean

fbeyrouti

  • Playmaker Newbie
  • *
  • Posts: 9
Re: Simulating Pre and Post Update of a state machine
« Reply #4 on: September 25, 2013, 08:49:34 AM »
Ya, I am a programmer :)

I am not sure doing pre-processing a frame earlier and post-processing a frame earlier will cut it for us. At this point I see the best way being adding the same actions to all the states.

Thanks for your reply

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Simulating Pre and Post Update of a state machine
« Reply #5 on: September 26, 2013, 01:36:57 AM »
Hi,

 Yes, and you'll also face issues with script execution order. This will also apply in playMaker, you don't know which state will be processed first amongst several Fsm running at the same time. So It's a pretty tuff challenge.

 Can you not have a central static class that deals with this computation and marshalling?

bye,

 Jean