Playmaker Forum
Bug Reporting => PlayMaker Bug Reporting => Topic started by: Nikaas on January 29, 2017, 07:03:19 PM
-
State machine variables doesn't seem to revert back to initial values at the end of playmode - this happens in the scene object and more strangely in its prefab too. The var change must be during action's Awake().
-
Hi,
Is it not an interface glitch? if you click and browse other fsm and back values persists?
Bye,
Jean
-
They persist.
But what I noticed is that this only happens if the gameObject/prefab is selected when hitting play. The FSM parent is even disabled on playmode (i.e. there is gameObject.SetActive(false) at the parent's Awake). All tests i done were on the starting state.
Additionally I noticed this happens if the vars are set at OnEnter, but there only FSMGameObject persist.
-
Hi,
Sorry for the delay :) please bump when you see that I lost track of posts.
can you tell your version of Unity? I assume you have the latest version of PlayMaker right?
Bye,
Jean
-
Unity is 5.6.0f3 and Playmaker 1.8.4.
-
Hi,
that's very odd, I can find a way to repro this.
Could you make a screencast showing what you do, then I may be able to understand what exactly is happening. That would really help as I can't fault this.
Bye,
Jean
-
Here is a video:
Notice how the int value is adding up on each run only when the game object / prefab is selected.
The code of the action is
public class Add : FsmStateAction
{
public FsmInt intVariable;
public FsmInt add;
public override void Awake()
{
intVariable.Value += add.Value;
}
public override void OnUpdate()
{
Finish();
}
}
-
Hi,
I see, I completly miss out on the awake thing. d'oh... :)
indeed, you should only use OnEnter and OnUpdate and Reset when you want to work with variables.
If you put a log in the awake you 'll see that awake if called on this action even if you use the action in a state that is not active. put a wait of 2 seconds in the start state and transit to a state where you use this action. the log is right when the fsm is initialized, not when the active state becomes the one with that action.
Bye,
Jean
-
Same happens in OnEnter and OnUpdate but only for FsmGameObject variables (there could be others, I haven't tried all var types).
-
Hi,
I can't repro this, can you paste a code snippet for me to test?
Thanks,
Bye,
Jean
-
I still can't get it if FSM variables should reset to pre-play mode values or they should remain to what they were changed-to during play mode (contrary to everything else in unity)?
If the FSM game object is selected in the hierarchy at the moment of clicking Stop the values are not reset, but if some other game object is selected at stop then the values are reset.
Next is a video how PM behaves differently in the 2 cases -
-
Are you still using 1.8.4?
Have you tried in 1.8.6?
-
I'm now with 1.8.6.
-
In the end the Awake() method in the actions is called as a consequence of OnInspectorGUI() (only when the game object is selected). And that happens after Stop is clicked.
-
Hi,
yeah, Ok I see. I will forward this to Alex, maybe this is something that can be improved to lift any misunderstanding.
Bye,
Jean