playMaker

Author Topic: Can we call two events on the same FSM from different places?  (Read 5060 times)

Netjera

  • Playmaker Newbie
  • *
  • Posts: 41
Can we call two events on the same FSM from different places?
« on: August 28, 2012, 06:57:13 PM »
I've got an FSM named "Check Tags".  It basically acts as a manager, checks the tags of an object and then determines what needs to be done.  I go out of it via a "Send Event" which calls another FSM on the same object.  However, when I try to go back into it via another event on its listener, it's not activating.

Can we point back to an FSM we pointed away from? 

Uttpd

  • Junior Playmaker
  • **
  • Posts: 70
Re: Can we call two events on the same FSM from different places?
« Reply #1 on: August 28, 2012, 08:40:28 PM »
humm not sure what your asking

If I understood it correctly you need to always go back to the first state (the listener state).
From the top off my head you can use: go to previous state and wait (x amount).
But if you need that Specific FSM State to be always on, maybe the best is never leave, and use broadcasting Events to all or specific FSMs

Humm not sure if that helps.. :-\

Netjera

  • Playmaker Newbie
  • *
  • Posts: 41
Re: Can we call two events on the same FSM from different places?
« Reply #2 on: August 29, 2012, 12:36:15 AM »
humm not sure what your asking

If I understood it correctly you need to always go back to the first state (the listener state).
From the top off my head you can use: go to previous state and wait (x amount).
But if you need that Specific FSM State to be always on, maybe the best is never leave, and use broadcasting Events to all or specific FSMs

Humm not sure if that helps.. :-\


Thanks for trying.  I guess I wasn't clear.  As a simplified example, I have 3 FSMs on the same object.  We'll call the object, ObjectX, and the FSMs are Check State, Check Panel, and Do Stuff.

All of them have a "Listener" state, with global events so that they can be called from anywhere.

Check State has TWO listeners.  One listener is just called "Listener" and it sends an event named "Check State".  The other listener is called "Move Listener" and it runs the MoveIt event.  When the game begins, Check State is activated at the Check State listener when someone clicks an object.  Then, after it runs the Check State FSM, that FSM calls the Check Panel FSM.  Once the Check Panel FSM runs, it calls the Do Stuff FSM.  When the Do Stuff FSM finishes, it calls the Check State FSM via the Move Listener event MoveIt.  A simple diagram:

GAME START -> MOUSE DOWN -> Check State FSM (Listener State/Check State Event) -> Check Panel FSM -> Do Stuff FSM -> Check State FSM (Move Listener State/MoveIt Event)

The sequence runs properly until the Do Stuff FSM finishes.  It goes all the way to its last state and sends the "Send Event" event to call the Check State FSM once more, but the MoveIt event on the Check State FSM never fires.  I wondered if it was because I was trying to come into the FSM from two different state/event combinations?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Can we call two events on the same FSM from different places?
« Reply #3 on: August 29, 2012, 02:26:13 AM »
Hi,

 Could it be that you are confused by the fact that a fsm can only be in one active state at a time. So if you a Fsm is called from two different places at the same time, the first call will likely get eaten and the series of actions and transitions it was supposed to perform not processed.

Have you used the debug flow system to go back on the steps and see the actual process, and what happened around that time? it's very easy to make sure that an action was fired etc etc.

bye,

 Jean

Netjera

  • Playmaker Newbie
  • *
  • Posts: 41
Re: Can we call two events on the same FSM from different places?
« Reply #4 on: August 31, 2012, 11:01:21 PM »
Hi,

 Could it be that you are confused by the fact that a fsm can only be in one active state at a time. So if you a Fsm is called from two different places at the same time, the first call will likely get eaten and the series of actions and transitions it was supposed to perform not processed.

Have you used the debug flow system to go back on the steps and see the actual process, and what happened around that time? it's very easy to make sure that an action was fired etc etc.

bye,

 Jean

I've got the FSMs linked together in a very linear way, where the first FSM fires, then calls the second, which calls the third, which goes back to the first at a different point.  It seems like all the actions are firing in order, exactly as I'd planned, but when they get to where they should call the original FSM, they're never going there.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Can we call two events on the same FSM from different places?
« Reply #5 on: September 03, 2012, 04:46:09 AM »
Hi,

 uhm.. not sure what's going on there, have you tried "next frame event" for when you want to call the original FSM?

bye,

 Jean