playMaker

Author Topic: Events fired near initialization time  (Read 2064 times)

turkeypotpie

  • Playmaker Newbie
  • *
  • Posts: 22
Events fired near initialization time
« on: January 02, 2013, 08:42:20 PM »
I have two state machines, FSM1 and FSM2.  I have four instances of FSM1, each on separate GOs.  I have one instance of FSM2 on its own GO.  All the GOs are part of the initial scene, so they should be created at (roughly) the same time.

Inside FSM1's start state, it fires off a global event.

Meanwhile, FSM2 is waiting for that event.

There are 4 instances of FSM1, but for some reason, FSM2 receives the global event 5 times.

I can workaround this problem by introducing a slight delay of .1s before the global event is fired.  Then FSM2 correctly receives 4 events.

The workaround works, but I'd rather not introduce arbitrary delays to solve such a problem.  This seems like a case that should work automatically.

« Last Edit: January 02, 2013, 08:46:10 PM by turkeypotpie »

Horror

  • Junior Playmaker
  • **
  • Posts: 79
Re: Events fired near initialization time
« Reply #1 on: January 03, 2013, 06:14:02 AM »
Have you tried pausing the game after all your FSMs have fired and stepping back through your states to make sure everything has worked as it should?

I usually try to avoid any situation in scripting where something is fired multiple times on the same object, in the same frame. You run the risk of having the first event being stomped by the second before it has a chance to finish what it was doing; then unpredictable stuff starts happening. I'm not sure why adding a .1s delay would change this, though...

If the above is the case, you could try creating a separate FSM2 for each of your FSM1's to send an event to; do a Send Event to Game Object FSM (don't use Broadcast All if you are using the same event name for each FSM).
« Last Edit: January 03, 2013, 06:23:43 AM by Horror »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Events fired near initialization time
« Reply #2 on: January 03, 2013, 06:26:03 AM »
Hi,

 that looks like bug ( even if I agree as well that such situation should be avoided when possible). Have you reported this using the bug report? if you have a repro package, that would be great as well.

bye,

 Jean