playMaker

Author Topic: change FSM global bool using c# script  (Read 3604 times)

goliath520

  • Playmaker Newbie
  • *
  • Posts: 7
change FSM global bool using c# script
« on: December 06, 2012, 11:09:17 PM »
I am difficulty changing a global boolean that appears in playmaker through c#. I searched around and most topics are related to getting a playmaker value and using it in a script but I want to modify it and have playmaker register it. Also, what would I use to make playmaker realize that this change happened? (Bool changed?) help would be greatly appreciated, I know its not that difficult I just don't know the syntax.

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: change FSM global bool using c# script
« Reply #1 on: December 07, 2012, 12:52:28 AM »
Try this:

Code: [Select]
FsmVariables.GlobalVariables.GetFsmBool("globalBoolName").Value = true;
Not sure what kind of change event you want?

The Bool Changed action just sends an event. You can do the same in script...

E.g., broadcast to all:
Code: [Select]
PlayMakerFSM.BroadcastEvent("boolChangedEvent");
Or send an event to an FSM:
Code: [Select]
var playMakerFSM = gameObject.GetComponent<PlayMakerFSM>();
playMakerFSM.Fsm.Event("boolChangedEvent");

Is that what you're looking for?

goliath520

  • Playmaker Newbie
  • *
  • Posts: 7
Re: change FSM global bool using c# script
« Reply #2 on: December 07, 2012, 02:26:59 AM »
Awesome! Thank you so much! Works perfectly, like I hoped.