playMaker

Author Topic: Externalizing FSMs  (Read 2046 times)

Laralyn

  • Playmaker Newbie
  • *
  • Posts: 21
Externalizing FSMs
« on: August 07, 2013, 01:16:08 PM »
Assume I have two separate FSMs (on two different game objects). FSM A is a loop that steps through code and then sends an event to FSM B, along with setting Variable A to the current step in the loop. Once it sends the event, FSM A moves on in the loop and FSM B executes separately.

So FSM A sends a GO event to FSM B, and sets Variable A = 1 on FSM B. FSM A moves on its loop, and FSM B starts its processing with Variable A = 1.

FSM A needs to send the GO event again with Variable A = 2 to FSM B. Do I need to explicitly start a loop to check the state of FSM B to make sure it's back to Idle (i.e. it has finished its processing and it's safe to send the event and reset Variable A), or does that happen automatically (i.e. the call from FSM A is queued and executes when FSM B finishes its current execution)?

I'm worried that either I would change Variable A out from under FSM B mid-stream, or that a call to FSM B would be lost because the GO event is only on its Idle state and if it's mid-stream on the first GO event, it would not be at a point where it could respond.

Thanks!

xhidnoda

  • Full Member
  • ***
  • Posts: 231
Re: Externalizing FSMs
« Reply #1 on: August 07, 2013, 04:35:48 PM »
In my experience...
You need to explicitly start a loop to check the state of FSM B to make sure it's back to Idle.