playMaker

Author Topic: Variables (in FSM instances and prefabs) not reset after playmode end  (Read 669 times)

Nikaas

  • Playmaker Newbie
  • *
  • Posts: 12
    • View Profile
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().


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12342
  • Official Playmaker Support
    • View Profile
Re: Variables (in FSM instances and prefabs) not reset after playmode end
« Reply #1 on: February 06, 2017, 10:45:14 PM »
Hi,

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

 Bye,

 Jean

Nikaas

  • Playmaker Newbie
  • *
  • Posts: 12
    • View Profile
Re: Variables (in FSM instances and prefabs) not reset after playmode end
« Reply #2 on: April 24, 2017, 11:57:19 AM »
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.
« Last Edit: April 24, 2017, 11:58:54 AM by Nikaas »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12342
  • Official Playmaker Support
    • View Profile
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

Nikaas

  • Playmaker Newbie
  • *
  • Posts: 12
    • View Profile
Unity is 5.6.0f3 and Playmaker 1.8.4.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12342
  • Official Playmaker Support
    • View Profile
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

Nikaas

  • Playmaker Newbie
  • *
  • Posts: 12
    • View Profile
Here is a video: https://youtu.be/zm4M422Yttk

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();
}
}

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12342
  • Official Playmaker Support
    • View Profile
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

Nikaas

  • Playmaker Newbie
  • *
  • Posts: 12
    • View Profile
Same happens in OnEnter and OnUpdate but only for FsmGameObject variables (there could be others, I haven't tried all var types).

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12342
  • Official Playmaker Support
    • View Profile
Hi,

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

Thanks,

 Bye,

 Jean