playMaker

Author Topic: FSM broadcast event to all?  (Read 6591 times)

mochatony

  • Playmaker Newbie
  • *
  • Posts: 7
FSM broadcast event to all?
« on: December 16, 2013, 10:47:48 AM »
Hello

Would like to know is the PlayMakerFSM.BroadcastEvent still working? I read that is deprecated but couldn't find relevant documentation elsewhere.

Also, BroadcastEvent and SendEvent, which is prefer method? Can I pay in value within the BroadcastEvent. Sorry, I have no idea where to get the api doc for this.

Thank you

Andy22

  • Junior Playmaker
  • **
  • Posts: 99
Re: FSM broadcast event to all?
« Reply #1 on: December 16, 2013, 11:07:14 AM »
Would like to know is the PlayMakerFSM.BroadcastEvent still working? I read that is deprecated but couldn't find relevant documentation elsewhere.

Where did u read its deprecated and yes still works.

Quote
Also, BroadcastEvent and SendEvent, which is prefer method? Can I pay in value within the BroadcastEvent. Sorry, I have no idea where to get the api doc for this.

They do different things, so there is no "prefer" PlayMakerFSM.BroadcastEvent will send the event to ALL Fsm's existing in your scene/game, while SendEvent() will send the event to the currently set Fsm.EventTarget or if null to itself.

For reasons i explained in a other thread for now i would suggest u use <see code>, if u try to communicate from a script to a Fsm.

Code: [Select]
PlayMakerUtils.SendEventToGameObject()

bye Andy
« Last Edit: December 16, 2013, 11:08:55 AM by Andy22 »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: FSM broadcast event to all?
« Reply #2 on: December 16, 2013, 01:05:42 PM »
Hi,

 note: "PlayMakerUtils" is not part of the official PlayMaker Package, it's available on the wiki with ArrayMaker:

https://hutonggames.fogbugz.com/default.asp?W715

or on its own ( may be a bit dated tho...)

http://hutonggames.com/playmakerforum/index.php?topic=3438.0

If you are targeting a very specific Fsm from script, I would recommend you simply create a public PlayMakerFsm variable ( let's call it 'MyFsm'), and work from there to send event to that fsm only using MyFsm.Fsm.Event("MY EVENT");


Bye,

 Jean
« Last Edit: December 17, 2013, 05:36:37 AM by jeanfabre »

Andy22

  • Junior Playmaker
  • **
  • Posts: 99
Re: FSM broadcast event to all?
« Reply #3 on: December 17, 2013, 04:14:40 AM »
create a public PlayMakerFsm variable ( let's call it 'MyFsm'), and work from there to send event to that fsm only using MyFsm.Event("MY EVENT");

Its actually <code>, since u need the actual Fsm class for this call, also keep in mind that if u ever use a "SetEventTarget" action in this Fsm, all events send this way will go to the target set in the action, also the "SentBy" and "Fsm Name" for the "event info" will be ofc from the Fsm u call the event on, so u cant hand over a custom sender object for the event.

Code: [Select]
MyFsm.Fsm.Event("MY EVENT")

bye Andy

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: FSM broadcast event to all?
« Reply #4 on: December 17, 2013, 05:35:27 AM »
Hi,

 Good catch, thanks Andy, it's corrected in the post itself.

Bye,

 Jean

mochatony

  • Playmaker Newbie
  • *
  • Posts: 7
Re: FSM broadcast event to all?
« Reply #5 on: December 17, 2013, 11:13:24 AM »
Thanks for helping out. Apparently I put the code at Awake block and it won't run, my guess is FSM is not ready then. :'(

Andy:

Quote
Where did u read its deprecated and yes still works.

I read from here. http://hutonggames.com/playmakerforum/index.php?topic=2383.msg10580#msg10580

Another question, is there a way for passing parameter for the SendEvent or BroadcastEvent. How do I retrieve the parameter from the FSM when it trigger?

Sorry. As I struggle to find relevante info from the documentation.
« Last Edit: December 17, 2013, 11:22:49 AM by mochatony »

Andy22

  • Junior Playmaker
  • **
  • Posts: 99
Re: FSM broadcast event to all?
« Reply #6 on: December 17, 2013, 12:14:36 PM »
U must use the globally static member:
Code: [Select]
Fsm.EventData
Be aware that because its globally the event needs to-be processed at the time its actually send, so don't use Invoke/Timers, since this will break the system. U have to use the DelayedEvent class for delayed events.

bye Andy