Playmaker Forum
PlayMaker News => General Discussion => Topic started by: BigDog on May 30, 2015, 07:15:03 PM
-
In my effect to practice good software engineering, I am trying to use "Run FSM" more. But I have come to a roadblock. I can't send event directly to the 'sub FSM'.
Before I used 'sub FSM', I have a state waiting on a event which gets send from C# script. Now this state is moved into the template. And it no longer received the event. How can I get send a event to a sub fsm?
Thanks
-
Hi, I just solved my own problem.
The trick is to use the obscure FSM property of the fsm.
HutongGames.PlayMaker.FsmEventTarget etarget = new HutongGames.PlayMaker.FsmEventTarget();
etarget.target = HutongGames.PlayMaker.FsmEventTarget.EventTarget.SubFSMs;
m_MovementFSM.Fsm.Event(etarget, "arrived");
Thanks.
-
Hi,
You have two entry point, PlayMakerFSM and FSM, PlayMakerFSM is the component itself ( that is dropped onto the GameObject), while the FSM is the actual class representing the fsm ( the visual canvas).
and so PlayMakerFSM compose some of the methods of FSM but no all. hence why some of the stuff is done via .Fsm
Bye,
Jean
-
I come across another issue with sending event to sub fsm. The issue is it doesn't work after one level of sub fsm. Is this by design or is this a bug? This makes the template system very limiting.
Thanks
-
I eventually managed send event to second level sub fsm from script. The trick is to set the events to global event, which I needn't had to do with the first level sub fsm.
Thanks
-
You can access sub FSMs directly using this property of Fsm:
public List<Fsm> SubFsmList
Then you can call Event(string eventName) or Event(FsmEvent event) on the sub FSM directly.
-
Great! That's what I need. Thanks!