playMaker

Author Topic: how to create a global event[SOLVED]  (Read 9916 times)

santelia

  • Junior Playmaker
  • **
  • Posts: 78
how to create a global event[SOLVED]
« on: June 15, 2012, 06:09:15 AM »
Really a noob question. I have to open and close a lot of doors. The doors are all duplicates of the same object, with two animations (open and close) included. They only have different names. So, before each door (both inside and outside) I have triggers that put the name of the active door in a global variable of kind GameObject. Now, I could have each door object with its own FSM to manage opening and closing of its door (Get Key Down specific keys, then open or close depending on key pressed, and change state of the door in open/closed by setting a global bool variable). But I'd surely prefer to call a single routine for the whole project, thus using only one FSM to manage opening and closing doors everywhere. So, the noob question is: how do I create a global event to be sent to another FSM?
« Last Edit: June 05, 2019, 04:02:34 AM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: how to create a global event
« Reply #1 on: June 15, 2012, 06:38:45 AM »
Hi,

 each events you create have a check box, tick this and it will become "global" and accessible anywhere by any Fsm. then you plug that event as a global transition on a state ( right click on the state -> add global transition) and from somewhere else, use the "send event" action and select that global event. Done.

 Bye,

jean

santelia

  • Junior Playmaker
  • **
  • Posts: 78
Re: how to create a global event
« Reply #2 on: June 15, 2012, 07:55:19 AM »
Thank you Jean. So, let me check if I have understood:

1) create an event and check its "global" checkbox;
2) out: create a "send event" action just where I need to launch that event, and send that global event to a specific object and FSM if possible, else with "broadcast to all" option checked;
3) in: where I need to receive the global event command, I create a global transition and assign to it the previously created global event, then add actions to be executed, as needed, to that state.

Is it ok? Did I forget anything?

And, how much CPU consuming is broadcast to all?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: how to create a global event
« Reply #3 on: June 15, 2012, 10:30:20 AM »
HI,

 yes, the process is ok as you describe it.

 Don't send event on each update or several times per update, that would not be good ( even in scripts, it would not). Then you can use broadcast all safely, I have a project with hundreds or Fsm, and global events everywhere,  broadcasting to all doesn't have any impact so far, so it will go a long way before any performance hit will be noticeable. Also, always test your scene when published, the Unity editor environment as well as the playmaker editing environment so have serious impacts on perfs, so testing properly publish in its final device or environment is a must to asset the performances.

 bye,

 Jean

PolyMad

  • Hero Member
  • *****
  • Posts: 545
Re: how to create a global event
« Reply #4 on: May 31, 2019, 10:45:13 AM »
I'm bringing this old topic back up because I'm having a strange problem with a Global Event.
You can see it in the video.
I set up a Global Event, but after selecting it on a state it says that it's unused anywhere.

Just to test, I tried to set up a brand new transition, set it global immediately and assigned it to the status.
Then I went to the other FSM and looked for it but it didn't appear in there (strange).
So I re-created it and made it global again in there, and called in the KEY action, same result.

HELP! I can't continue without this!

Unity 2018.3.6f1
Playmaker 1.9.0.p12
« Last Edit: May 31, 2019, 11:35:29 AM by megmaltese »

PolyMad

  • Hero Member
  • *****
  • Posts: 545
Re: how to create a global event
« Reply #5 on: June 03, 2019, 08:24:50 AM »
Ehm... up I guess...

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: how to create a global event
« Reply #6 on: June 05, 2019, 04:02:14 AM »
Hi,

 yes, because this action is sending the event locally only, so it doesn't find it in the fsm.

 either use SetEventTarget action to setup where event should be sent and you can pick broadcast or make a local event that transit to a new state that use send event action.

 Bye,

 Jean