Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: turkeypotpie on May 17, 2014, 08:30:47 PM
-
I'm seeing the following strange behavior:
1. I have an fsm attached to my GameObject. It is initially disabled when the program starts. 'Reset on Disable' is set to true. I have a custom FsmStateAction on one of my states with 'OnEnter' and 'OnExit' overridden.
2. After the program starts I enable my fsm. OnEnter is called.
3. Later, I disable my fsm. OnExit is called.
4. Still later, I enable my fsm again. OnExit is called a second time, and then OnEnter is called.
So why is OnExit being called again in Step #4? It really messes up my game logic. Is there any good way to detect whether the call is happening the second time so I can filter it out?
Btw, my fsm is basically a subfsm within a larger state machine. It's enabled / disabled with the EnableFSM action.
-
I'll see if I can repro this here...
-
Cool. Thank you.
For me, it shows up with PlayMaker 1.7.7.1 on Unity 4.3.4, using a clean project.
-
Hi, I can confirm this is a bug :(
The workaround until we fix this is to add a little extra logic to your action so OnExit checks if the action was entered:
public class ActionLifeCycleFix : FsmStateAction
{
private bool entered;
public override void OnEnter()
{
entered = true;
...
}
public override void OnExit()
{
if (!entered) return;
...
entered = false;
}
}
Only a few of the built in actions use OnExit and in those cases it doesn't matter if it's called twice, so it took a while to catch this bug - sorry!
This will be fixed in the next update, and we've added it to our automated tests now, so it shouldn't break again... thanks for your patience :-\
-
Cool. Thanks for the fix on this ... and the workaround too. :)
-
Hi,
I'm still seeing this issue in version 1.7.8, is this supposed to be fixed?
Thanks.
-
Bump? (Despite the date, it wasn't an April fool.)