playMaker

Author Topic: Transition after multiple actions have completed execution.  (Read 2807 times)

telpokint

  • Playmaker Newbie
  • *
  • Posts: 3
Transition after multiple actions have completed execution.
« on: October 11, 2013, 03:14:38 PM »
I have states with multiple (let's say 10) actions (most of them are move to position actions).  I want to transition to the next state when all the actions have finished, i.e. when all the objects have reached their destination.  I can think of two cumbersome ways to do this:

1) Make 10 identical states, and have each action send the same NEXT event on end.  Then have the 11th state be the actual state I want to transition to when all are completed.

2) Find out which action will take the longest, and only transition when it is done.

1) seems ridiculously cumbersome, and especially because I have many states where I do this kind of thing, so my FSM will be filled with identical states.

2) Seems impossible and also cumbersome, because in a dynamic environment it would be hard to know which action would end earliest.

Is there an easy way to do this in Playmaker, or will I just have to write my own script?

telpokint

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Transition after multiple actions have completed execution.
« Reply #1 on: October 11, 2013, 04:16:29 PM »
Actually I just tried to implement 1) and realized that it's not feasible, because the first object that reaches it's destination will just send the end event N times, so it'll transition to the next part as soon as the first one arrives, not when all of them arrive.

Is there any way to only transition when all actions have finished?

mikejkelley

  • Full Member
  • ***
  • Posts: 136
Re: Transition after multiple actions have completed execution.
« Reply #2 on: October 11, 2013, 06:00:34 PM »
ArrayListGetMaxFloat, store the game obj. w/ this dist. value as a var, compare the var, send event when var=0? I'm new to playmaker, so this may not be what you want/or work.

telpokint

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Transition after multiple actions have completed execution.
« Reply #3 on: October 12, 2013, 07:18:48 PM »
So I basically have to write my own script to do all of the logic?  There's no way to do it natively in playmaker?

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: Transition after multiple actions have completed execution.
« Reply #4 on: October 13, 2013, 07:47:44 AM »
The state sends a FINISHED event when all actions on the state have finished. You can use this to transition to another state.

You could also have a separate FSM watch for transition conditions, and send events to the first FSM. Basically a Controller FSM that sends events to an FSM that knows what to do with them. This separation is often a good idea. It lets you swap controllers out, e.g., player controller, AI controller, cut-scene controller... It can also make it easier to test different behaviors. If all the logic/behavior/animation etc. is all in one FSM it can quickly become hard to iterate/change/test...