playMaker

Author Topic: 2 send events in one state? [SOLVED]  (Read 2964 times)

kinetiknz

  • Junior Playmaker
  • **
  • Posts: 85
2 send events in one state? [SOLVED]
« on: November 22, 2011, 10:25:49 PM »
Hey there, I am just adding some extras to a project I am working on. I'm trying to understand how branching in multiple directions is supposed to be handled.

eg. a scene where the user clicks and I wish to send 2 events (activate 2 different fsm's) from the one FSM. I know an FSM can only have one current action, but states finish when they encounter a send events don't they?? Is it possible to somehow trigger more than 1 send event inside one state?

I have been using other methods, like flipping a bool inside FSM 1 and detecting the bool flip in FSM 2, but it's unwieldy and not very elegant.

Am I misunderstanding something?
« Last Edit: November 30, 2011, 10:28:27 PM by alexchouls »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: 2 send events in one state?
« Reply #1 on: November 23, 2011, 10:06:17 AM »
Hi,

 This is simple:

 have a state that sends an event. That event has a "FINISH" transition, and lead to another state that sends your second event. Done.
What happens is that the first state sends that event, and straight away transit to the next state because it's finished ( assuming you are only using a send event action, no "every frame" actions, otherwise the "finish event doesn't trigger automatically).

 So infact you could have a whole bunch of states doing a particular job in one go with no latency. I use that very much. for example I send an event, then for clarity I move to another state to set variables, then move to another state to do some checks and so on. All of them or instant actions as if part of the same "function" in normal scripting.

Splut up your tasks, It's perfectly acceptable to have one little thin to do per state, nothing wrong with that, don't try to be more "efficient" by stacking actions into one state, it will be better to organize and divide. it will pay off big time and really help you in the long run to debug, and come back to this fsm and understand what it does by just glancing, instead of opening each state and look at whyt actions does. This is something I try to avoid at all cost, I should not have to open a state to understand what it does, the state label should be enough ( with a description for more clarity).


 Hope this helps,

 Jean

 

kinetiknz

  • Junior Playmaker
  • **
  • Posts: 85
Re: 2 send events in one state?
« Reply #2 on: November 23, 2011, 05:23:09 PM »
Hi Jean, thanks for that. I feel pretty stupid now. I presumed that send event finished the processing of that state, including finished events.

Thanks alot for your replies. Always very helpful and in-depth.