Playmaker Forum

Bug Reporting => PlayMaker Bug Reporting => Topic started by: Nikaas on January 29, 2017, 07:03:19 PM

Title: Variables (in FSM instances and prefabs) not reset after playmode end
Post 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().

Title: Re: Variables (in FSM instances and prefabs) not reset after playmode end
Post by: jeanfabre on February 07, 2017, 12:45:14 AM
Hi,

 Is it not an interface glitch? if you click and browse other fsm and back values persists?

 Bye,

 Jean
Title: Re: Variables (in FSM instances and prefabs) not reset after playmode end
Post by: Nikaas on April 24, 2017, 02:57:19 PM
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.
Title: Re: Variables (in FSM instances and prefabs) not reset after playmode end
Post by: jeanfabre on May 15, 2017, 04:48:37 AM
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
Title: Re: Variables (in FSM instances and prefabs) not reset after playmode end
Post by: Nikaas on May 15, 2017, 03:27:14 PM
Unity is 5.6.0f3 and Playmaker 1.8.4.
Title: Re: Variables (in FSM instances and prefabs) not reset after playmode end
Post by: jeanfabre on May 17, 2017, 02:56:55 AM
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
Title: Re: Variables (in FSM instances and prefabs) not reset after playmode end
Post by: Nikaas on May 17, 2017, 04:23:19 PM
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
Code: [Select]
public class Add : FsmStateAction
{
public FsmInt intVariable;
public FsmInt add;

public override void Awake()
{
intVariable.Value += add.Value;
}

public override void OnUpdate()
{
Finish();
}
}
Title: Re: Variables (in FSM instances and prefabs) not reset after playmode end
Post by: jeanfabre on May 23, 2017, 03:30:06 AM
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
Title: Re: Variables (in FSM instances and prefabs) not reset after playmode end
Post by: Nikaas on May 23, 2017, 06:09:28 PM
Same happens in OnEnter and OnUpdate but only for FsmGameObject variables (there could be others, I haven't tried all var types).
Title: Re: Variables (in FSM instances and prefabs) not reset after playmode end
Post by: jeanfabre on June 16, 2017, 09:13:28 AM
Hi,

 I can't repro this, can you paste a code snippet for me to test?

Thanks,

 Bye,

 Jean
Title: Re: Variables (in FSM instances and prefabs) not reset after playmode end
Post by: Nikaas on January 06, 2018, 09:29:07 PM
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 -
Title: Re: Variables (in FSM instances and prefabs) not reset after playmode end
Post by: Alex Chouls on January 06, 2018, 10:47:53 PM
Are you still using 1.8.4? 
Have you tried in 1.8.6?
Title: Re: Variables (in FSM instances and prefabs) not reset after playmode end
Post by: Nikaas on January 07, 2018, 02:29:44 AM
I'm now with 1.8.6.
Title: Re: Variables (in FSM instances and prefabs) not reset after playmode end
Post by: Nikaas on January 07, 2018, 07:19:03 PM
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.
Title: Re: Variables (in FSM instances and prefabs) not reset after playmode end
Post by: jeanfabre on January 10, 2018, 02:41:24 AM
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