playMaker

Author Topic: SetFsmVariable sometimes setting wrong values  (Read 2735 times)

PollitronicDev

  • Playmaker Newbie
  • *
  • Posts: 13
SetFsmVariable sometimes setting wrong values
« on: September 19, 2018, 06:05:13 AM »
Hello there!

This is my setup:

- I have a prefab with 2 FSMs: FSMa and FSMb.
- Each of these FSMs has a (float) variable: VarA and VarB.

Now I need to set VarB (in FSMB) to the value of VarA (in FSMA), so from FSMA I use a SetFsmVariable action as shown in the image.

The problem is that, when running an instance of the prefab and executing the action, the value passed to VarB is always the value VarA had originally (the one set in the Variables tab). In other words, the action ignores any changes done at runtime to VarA, it always sends the original value. I suspect it might be sending the value in the prefab instead of the one in the instance.

Strangely, there was one execution in which the values passed were correct. However, the next time I executed the game (I changed nothing) it went back to the wrong behaviour, and kept like this.

Any idea of what can be causing this (bug?), or if I'm doing something wrong?

Thanks in advance!

miguelfanclub

  • Full Member
  • ***
  • Posts: 165
Re: SetFsmVariable sometimes setting wrong values
« Reply #1 on: October 09, 2018, 06:33:37 AM »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: SetFsmVariable sometimes setting wrong values
« Reply #2 on: October 10, 2018, 06:56:56 AM »
Hi,

On what version of Unity are you working?
 
Bye,

 Jean

PollitronicDev

  • Playmaker Newbie
  • *
  • Posts: 13
Re: SetFsmVariable sometimes setting wrong values
« Reply #3 on: November 05, 2018, 04:53:59 AM »
    Hello there, sorry for the delay!

    Currently I'm using Unity 2018.2.3f1

    Thanks and regards!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: SetFsmVariable sometimes setting wrong values
« Reply #4 on: November 07, 2018, 03:16:16 AM »
Hi,

 Could you share the scene you are testing this with? all seems well here.

Bye,

 Jean

PollitronicDev

  • Playmaker Newbie
  • *
  • Posts: 13
Re: SetFsmVariable sometimes setting wrong values
« Reply #5 on: November 08, 2018, 04:49:34 AM »
    Sure thing!

    Just drop the included package in an empty scene (with PlayMaker installed). There is a single object with two FSMs (FSMa and FSMb), each with a float variable (VarA and VarB). FSMb is empty, and the only thing FSMa does is change VarA's value and then set FSMb's VarB to VarA's value.

    When executing, you will see what is shown in the image included: even if VarA has been set to 10, VarB has been changed to 1 (which is VarA's initial value).

    An interesting thing I found - if we tick the 'Every Frame' box in the SetFsmVariable action, then the first frame it will display the behaviour described above, then in the next frame it will send the correct value. This suggests something is probably missing in FSMSetVariable's OnEnter() ?

    Thanks and regards!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: SetFsmVariable sometimes setting wrong values
« Reply #6 on: November 13, 2018, 02:27:04 AM »
Hi,

Good Catch.

 I have escalated the issue, hopefully the next update will have the fix. Meanwhile, use SetFsmVariable2 from the Ecosystem. WARNING: you need the PlayMaker Utils package. You can also get it from the Ecosystem

Let me know how it goes.

Bye,

 Jean

PollitronicDev

  • Playmaker Newbie
  • *
  • Posts: 13
Re: SetFsmVariable sometimes setting wrong values
« Reply #7 on: November 22, 2018, 04:41:17 AM »
    Much appreciated. Thanks a lot! :)