playMaker

Author Topic: Instance of FSM  (Read 2051 times)

Elzean

  • Playmaker Newbie
  • *
  • Posts: 1
Instance of FSM
« on: June 08, 2012, 11:54:38 PM »
Hi,

i really like to use Playmaker, i was wondering if there was a way to share the same fsm across several objects. I would like to make some small fsm, for example i have one listening for a hit event and receiving a "damage" info (an int) and adjusting the current life of the owner. This kind of fsm could evolve during the development but will be placed on several prefabs. So if change one "life manager fsm" i would like the change to be reflected on every prefab where this fsm appear, adding states, action,...

So i would like to know if i miss something or if its simply not possible ?

Thanks !

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Instance of FSM
« Reply #1 on: June 09, 2012, 01:46:02 AM »
Hi,

 For this, I would suggest you create a prefab with the functionnality you want, and create/attach it at runtime where you need it. this way you have one single fsm.

I have a working example of such set up:
http://hutonggames.com/playmakerforum/index.php?topic=1366.0

But from your description, you can go for a direct approach to have a fsm manage at the top level of your prefab that knows what it wants to implement and simply attach as child the required "snippets". If your snippets knows that they are always the child of their owner, when they start, they simply query for their parent, and work with this in all their actions ( essentially ignoring their own gameObject).

 Bye,

 Jean