playMaker

Author Topic: possible to send same fsm event to multiple objects at once?[SOLVED]  (Read 2858 times)

Gav (HeyBud)

  • Full Member
  • ***
  • Posts: 126
    • Tumblr
I'm trying to send an event to 15 copies of the same object and effect them all at once. All of the objects have the same FSM. The only way I can think of sending it is to name them numerically i.e. clone_1 clone_2 clone_3 etc. (They don't need to be prefabs) and then have 15 send event actions.  But I would like to send them all at the same time if possible. Any ideas on how to send the event on them all at once with one action? I also tried making a global GO var and sending a global event to the global GO variable in hopes that all the game objects with that var would send,  but that only effected one random clone. Thanks for any ideas.
« Last Edit: March 11, 2014, 07:47:33 AM by jeanfabre »

blackant

  • Hero Member
  • *****
  • Posts: 521
  • http://blackantmaster.com
    • blackantmaster.com
Re: possible to send same fsm event to multiple objects at once?
« Reply #1 on: March 08, 2014, 05:28:27 AM »
you should set your event as "global" first and right clic on the state that you want started by this event on the objects you want to listen it, and select Add global Transition

Gav (HeyBud)

  • Full Member
  • ***
  • Posts: 126
    • Tumblr
Re: possible to send same fsm event to multiple objects at once?
« Reply #2 on: March 08, 2014, 11:26:19 PM »
Yeah, I did that. It still only sends to one of the objects with that global event. Thanks, though.

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: possible to send same fsm event to multiple objects at once?
« Reply #3 on: March 09, 2014, 12:09:52 AM »
You could use the Broadcast All option in Send Event with an event that only those copies are listening for.

Or you could use the GameObject option with Send To Children checked, and parent your copies to a common parent.

The next update will have native support for arrays which will let you fill an array with the target objects and send an event to each target. You could build a loop manually now, but it would be more work If one of the methods above works for you I'd go with that...

There may also be custom actions that do other things, like send an event to all GameObjects with a given Tag... I seem to remember seeing something like that...

Gav (HeyBud)

  • Full Member
  • ***
  • Posts: 126
    • Tumblr
Re: possible to send same fsm event to multiple objects at once?
« Reply #4 on: March 09, 2014, 04:42:36 AM »
The second option worked great since I already had them parented. Who knew the solution was a check box I overlooked. Thank you. The broadcast will come in handy, too. I look forward to the updates with array support.