playMaker

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

Carmichael

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

djaydino

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

Carmichael

  • Full Member
  • ***
  • Posts: 228
    • View Profile
Re: Send event directly from script?
« Reply #2 on: July 27, 2017, 11:50:56 AM »
wow thank you

jeanfabre

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

Carmichael

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