playMaker

Author Topic: How to create an FSM with a breakable action loop?  (Read 1474 times)

SwabbyNat

  • Playmaker Newbie
  • *
  • Posts: 1
How to create an FSM with a breakable action loop?
« on: October 28, 2013, 01:12:17 PM »
I'm still fairly new to Playmaker, and any help on this one would be GREATLY appreciated.

Here's what i'm trying to do.

I have an NGUI Record button that has a global variable attached to it of a 'maxTime' of 30 seconds (int). Once the user presses the record button:

1) change a 'isRecording' boolean to 'true'
2) set a currentRecTime to zero
3) start a looping action:
    3a) do a bool compare: isRecording == true?
    3b) do a int compare: is currentRecTime < maxTime
(IF 3b == true)
    3c) 'wait' for 1 second
    3d) add +1 to the currentRecTime, then repeat 3a
(IF 3b == false)
4) change a 'isRecording' boolean to 'false'

Now this ALL works fine, but how can i add an action to an NGUI -ON CLICK- event that essentially sets 'isRecording' to false, which would break the loop above before the time runs out?

I've been wracking my brain trying different setups, but the looping action always seems to take over the FSM, and i can seem to get the NGUI on click event to register.

Help?

Nathaniel Hunter
SuperTales

Red

  • Hero Member
  • *****
  • Posts: 563
Re: How to create an FSM with a breakable action loop?
« Reply #1 on: October 28, 2013, 07:30:27 PM »
I'd probably put the breaking action in a separate FSM... that way you can have the timing be independent than the "waiting to break out" fsm.

As for the NGUI bits, well, I'm not sure I can answer that but it shouldn't be too difficult with the PM-to-NGUI system that Jean has been kind enough to develop or even the PM-to-NGUI action pack on the asset store (I've used it and it's pretty decent.)