Playmaker Forum

Bug Reporting => PlayMaker Bug Reporting => Topic started by: PollitronicDev on September 19, 2018, 06:05:13 AM

Title: SetFsmVariable sometimes setting wrong values
Post by: PollitronicDev 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!
Title: Re: SetFsmVariable sometimes setting wrong values
Post by: miguelfanclub on October 09, 2018, 06:33:37 AM
I suspect is related to this as well:
https://hutonggames.com/playmakerforum/index.php?topic=19540.0 (https://hutonggames.com/playmakerforum/index.php?topic=19540.0)
Title: Re: SetFsmVariable sometimes setting wrong values
Post by: jeanfabre on October 10, 2018, 06:56:56 AM
Hi,

On what version of Unity are you working?
 
Bye,

 Jean
Title: Re: SetFsmVariable sometimes setting wrong values
Post by: PollitronicDev 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!
Title: Re: SetFsmVariable sometimes setting wrong values
Post by: jeanfabre 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
Title: Re: SetFsmVariable sometimes setting wrong values
Post by: PollitronicDev 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!
Title: Re: SetFsmVariable sometimes setting wrong values
Post by: jeanfabre 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
Title: Re: SetFsmVariable sometimes setting wrong values
Post by: PollitronicDev on November 22, 2018, 04:41:17 AM
    Much appreciated. Thanks a lot! :)