Playmaker Forum

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

Title: Send event directly from script?[SOLVED]
Post by: Ofonna on July 26, 2017, 01: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, 11:12:44 AM
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, 11:50:56 AM
wow thank you
Title: Re: Send event directly from script?
Post by: jeanfabre on July 31, 2017, 12: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, 12:50:06 AM
thank you Jean!