playMaker

Author Topic: How to run FSMs in parallel  (Read 142 times)

homeworld

  • Playmaker Newbie
  • *
  • Posts: 25
    • View Profile
How to run FSMs in parallel
« on: August 25, 2017, 02:29:44 AM »
Hi! Sorry if this is a common question, but it's nebulous enough that i don't know how to effectively search for it:

I was looking into designing a tractor beam system for powerups in my game, and got caught in the part where more than one powerup needs to get 'magnetized' at a time! I thought that maybe i could use 'run FSM', but the state won't end until the template ends.

I can't think of any other way to do this, any help is greatly appreciated!

elusiven

  • Full Member
  • ***
  • Posts: 227
  • Debt we all must pay...
    • View Profile
Re: How to run FSMs in parallel
« Reply #1 on: August 25, 2017, 03:06:33 AM »
What happens when you put "FINISHED" where the run template action is? Is it not continuing while template is running? Also you can have multiple FSMs on one object and have them launch at the same time. I don't fully understand what you are trying to achieve, i'm sure it's solvable though.

homeworld

  • Playmaker Newbie
  • *
  • Posts: 25
    • View Profile
Re: How to run FSMs in parallel
« Reply #2 on: August 25, 2017, 03:54:17 AM »
Hi Elusiven! It seems like the state waits for the template fsm to complete before proceeding to the FINISHED event, which leads to this happening:

http://danbkp.myqnapcloud.com/Web/2017-08-25_13-50-52.webm

Although not horrible, i'd much prefer if all the powerups would magnetize at the same time instead of waiting for their turn! It's a fast-paced game so it's kind of important for the player to grab all the powerups with minimal hassle! Thanks for the reply!

elusiven

  • Full Member
  • ***
  • Posts: 227
  • Debt we all must pay...
    • View Profile
Re: How to run FSMs in parallel
« Reply #3 on: August 25, 2017, 05:37:27 AM »
What is your implementation at the moment? How are they triggered to magnetise to the player? Usually what I would do for objects such as power ups is to treat them as an "object" of some type. The object would be a prefab, and would share it's logic and then I would probably send an event to all objects with the same tag to do something. Would that not work for you? Tag the prefab of the power, and then on some event they will all do something providing that the event has been sent to all of them. You could even on X event, make them run specific template for each

HeathClose

  • Full Member
  • ***
  • Posts: 223
    • View Profile
Re: How to run FSMs in parallel
« Reply #4 on: August 25, 2017, 05:46:59 AM »
I would think a structure where a "send event broadcast all" would trigger all the items at the same time...

homeworld

  • Playmaker Newbie
  • *
  • Posts: 25
    • View Profile
Re: How to run FSMs in parallel
« Reply #5 on: August 25, 2017, 06:22:26 AM »
Right now, i just have a FSM on the player that pulls the powerup objects towards it on trigger collide; I was trying to avoid adding FSMs to every powerup, considering i've already got way too many FSMs (over a thousand) due to my level generator; but maybe just activating them on trigger for the purpose of the tractor beam is fine!