playMaker

Author Topic: Send event directly from script?[SOLVED]  (Read 6117 times)

Ofonna

  • Full Member
  • ***
  • Posts: 230
Send event directly from script?[SOLVED]
« 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!
« Last Edit: August 03, 2017, 03:50:05 AM by jeanfabre »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Send event directly from script?
« Reply #1 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")

Ofonna

  • Full Member
  • ***
  • Posts: 230
Re: Send event directly from script?
« Reply #2 on: July 27, 2017, 02:50:56 PM »
wow thank you

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Send event directly from script?
« Reply #3 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

Ofonna

  • Full Member
  • ***
  • Posts: 230
Re: Send event directly from script?
« Reply #4 on: July 31, 2017, 03:50:06 AM »
thank you Jean!