Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: ssc.mikey on December 12, 2013, 04:07:44 AM

Title: multiple fsm
Post by: ssc.mikey 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");
   }
Title: Re: multiple fsm
Post by: Andy22 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