playMaker

Author Topic: multiple fsm  (Read 1800 times)

ssc.mikey

  • Playmaker Newbie
  • *
  • Posts: 1
multiple fsm
« on: December 12, 2013, 04:07:44 AM »
Hi. I can't find anything useful on web so i would like to ask how to access fsm from c# script. I have a manager with few fsm's attached to it called pop_up, purchase, leaderboard, achievement etc. When i want to access any of this it works only if i call them FSM. Once i change the name it doesn't work anymore so i would like to know what do i need to change on the script below. Really appreciate your help. Thank you.


PlayMakerFSM fsmFireEvent;
   
   void Start ()
   {
      fsmFireEvent = gameObject.GetComponent<PlayMakerFSM>();
   }

        public void Purchase ()
   {
      fsmFireEvent.Fsm.Event ("purchase_no_1");
   }

Andy22

  • Junior Playmaker
  • **
  • Posts: 99
Re: multiple fsm
« Reply #1 on: December 12, 2013, 04:41:06 AM »
Hi,

u have two options, either use:
Code: [Select]
PlayMakerFSM.BroadcastEvent("purchase_no_1");which will send this event to all FSM's globally. So if "purchase_no_1" is globally unique this will work or u need to get the specific FSM with the name via:

Code: [Select]
var fsm = PlayMakerFSM.FindFsmOnGameObject(gameObject, "purchase");
if (fsm != null) {
    fsm.SendEvent("purchase_no_1");
}

bye Andy