Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Gav (HeyBud) on March 08, 2014, 03:08:49 AM

Title: possible to send same fsm event to multiple objects at once?[SOLVED]
Post by: Gav (HeyBud) on March 08, 2014, 03:08:49 AM
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.
Title: Re: possible to send same fsm event to multiple objects at once?
Post by: blackant 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
Title: Re: possible to send same fsm event to multiple objects at once?
Post by: Gav (HeyBud) 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.
Title: Re: possible to send same fsm event to multiple objects at once?
Post by: Alex Chouls 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...
Title: Re: possible to send same fsm event to multiple objects at once?
Post by: Gav (HeyBud) 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.