playMaker

Author Topic: "Object reference" error when using Fsm.BroadcastEvent [SOLVED]  (Read 2138 times)

kiko

  • Playmaker Newbie
  • *
  • Posts: 17
"Object reference" error when using Fsm.BroadcastEvent [SOLVED]
« on: February 14, 2014, 07:46:57 PM »
When using this method in a C# script:

Fsm.BroadcastEvent("MyEvent", true);

i get the following compile error:

      error CS0120: An object reference is required to access non-static member `HutongGames.PlayMaker.Fsm.BroadcastEvent(string, bool)'

I think it's related to this thread?

http://hutonggames.com/playmakerforum/index.php?topic=52.0

I'm sure this is just me not understanding some basic concepts. Could someone please help break down what I'm doing wrong?
« Last Edit: February 14, 2014, 09:20:02 PM by kiko »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4002
  • Official Playmaker Support
    • LinkedIn
Re: "Object reference" error when using Fsm.BroadcastEvent
« Reply #1 on: February 14, 2014, 08:58:49 PM »
For that call you need a reference to the Fsm that is broadcasting the event.

Code: [Select]
public void BroadcastEvent(FsmEvent fsmEvent, bool excludeSelf = false)
If you don't have an Fsm reference, use this static method:

Code: [Select]
PlayMakerFSM.BroadcastEvent("MyEvent");

kiko

  • Playmaker Newbie
  • *
  • Posts: 17
Re: "Object reference" error when using Fsm.BroadcastEvent
« Reply #2 on: February 14, 2014, 09:19:16 PM »
Ok yup wouldn't have ever figured that static method out.  :P

Thank you!