Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Ofonna on July 26, 2017, 04:59:10 PM

Title: Send event directly from script?[SOLVED]
Post by: Ofonna on July 26, 2017, 04:59:10 PM
High guys, just wondering if it's possible for me to send events to my fsm directly from my script.

thanks!
Title: Re: Send event directly from script?
Post by: djaydino on July 27, 2017, 02:12:44 PM
Hi, yes you can :D

you will need to add
Code: [Select]
using HutongGames.PlayMaker;
to broadcast you can use :
Code: [Select]
PlayMakerFSM.BroadcastEvent("TheEvent");

to send to a specific fsm you can do this :

Code: [Select]
GoFsm = GameObject.GetComponent<PlayMakerFSM>();
        GoFsm.SendEvent("TheEvent")
Title: Re: Send event directly from script?
Post by: Ofonna on July 27, 2017, 02:50:56 PM
wow thank you
Title: Re: Send event directly from script?
Post by: jeanfabre on July 31, 2017, 03:02:40 AM
Hi,

 also, you can get the PlayMaker Utils ( you might already have it on the Project), and it has a bunch or calls to make sending events from scripts even more powerful.

like: PlayMakerUtils.SendEventToGameObject(PlayMakerFSM fromFsm,GameObject target,string fsmEvent,bool includeChildren,FsmEventData eventData)

this will target a GameObject specifically, with lots of options ( all the one you get when sending even from an action basically).

pass null to "fromFsm" and it will create a proxy to send an event :)

these utils are used on all proxies ( ugui, photon, animator, pathfinding, etc, etc)


 Bye,

 Jean
Title: Re: Send event directly from script?
Post by: Ofonna on July 31, 2017, 03:50:06 AM
thank you Jean!