playMaker

Author Topic: PlayMakerFSM.BroadcastEvent not working often  (Read 1626 times)

protozerg

  • Playmaker Newbie
  • *
  • Posts: 7
PlayMakerFSM.BroadcastEvent not working often
« on: June 03, 2016, 03:31:11 PM »
Hi,

I'm using Playmaker 1.7.8.4 in my game.

At the end of game stage a result popup is shown by a code in Unity like below.

Most of time the event message is sent to FSM correctly,

but about one out of thirty times FSM can not receive the event

event though the game object with the FSM always active and never destroyed.

BroadcastEvent is called in a function which was called by Invoke function,

but every time Invoke worked correctly.

I also put some logs between code and actions in FSM to check the state of

FSM with the event is called or not.

Let me get out of this weird trouble, please.

Thanks

Code: [Select]
void AFunction()
{
    Invoke("ShowRewardWin", 3.0f);
}

void ShowRewardWin()
{
    //...........

    PlayMakerFSM.BroadcastEvent("PMGUI/Global/GameStageEnd");


Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4003
  • Official Playmaker Support
    • LinkedIn
Re: PlayMakerFSM.BroadcastEvent not working often
« Reply #1 on: June 03, 2016, 03:56:46 PM »
Is the receiving event definitely in the expected state to receive the event?
Are you using Global Transitions to respond to the event?

Normally this is an update order problem. GameObjects and Components are updated in an arbitrary order in Unity every frame. So sometimes GameObjects and Components are not actually in the state you think they are in when another GameObject calls them (or sends an event).

protozerg

  • Playmaker Newbie
  • *
  • Posts: 7
Re: PlayMakerFSM.BroadcastEvent not working often
« Reply #2 on: June 03, 2016, 04:09:23 PM »
Yes, I'm using global transition for the event.

If it is an update order problem, how can I solve it?

Do I need to call FSM directly to the game object like this?

 
Code: [Select]
PlayMakerFSM fsm = PlayMakerFSM.FindFsmOnGameObject(go, "FSM");
fsm.SendEvent("PMGUI/Global/GameStageEnd");