Playmaker Forum

Bug Reporting => PlayMaker Bug Reporting => Topic started by: DanielThomas on June 04, 2019, 10:01:58 PM

Title: Run FSM: InvalidCastException: Specified cast is not valid. [FIXED]
Post by: DanielThomas on June 04, 2019, 10:01:58 PM
I have a FSM Template with an exposed string variable (like hostVariableName). I use 'Run FSM' with the template and use a variable (like float) with the convert option in the variable pulldown menu.

It gives "InvalidCastException: Specified cast is not valid." when I ran.

It's obviously easy to avoid, but it does come as a surprise and it's not super easy to find the problem unless you know that's the only thing you changed.
Title: Re: Run FSM: InvalidCastException: Specified cast is not valid.
Post by: Alex Chouls on June 05, 2019, 01:09:48 AM
Thanks for the report, I’ll see if I can repro here.
Can you copy/paste the full error.
Also what versions of Playmaker and Unity?
Title: Re: Run FSM: InvalidCastException: Specified cast is not valid.
Post by: DanielThomas on June 05, 2019, 08:09:07 AM
Ah yes, sorry.
Unity 2018.3.12f1, Playmaker 1.9.0.p15 (and p7).
I was able to repro it in a new project.
Error is:
Code: [Select]
InvalidCastException: Specified cast is not valid.
HutongGames.PlayMaker.FsmVar.ApplyValueTo (HutongGames.PlayMaker.INamedVariable targetVariable) (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/FsmVariables/FsmVar.cs:671)
HutongGames.PlayMaker.FsmVarOverride.Apply (HutongGames.PlayMaker.FsmVariables variables) (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/CustomActionTypes/FsmVarOverride.cs:33)
HutongGames.PlayMaker.FsmTemplateControl.ApplyOverrides (HutongGames.PlayMaker.Fsm overrideFsm) (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/CustomActionTypes/FsmTemplateControl.cs:133)
HutongGames.PlayMaker.FsmTemplateControl.InstantiateFsm () (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/CustomActionTypes/FsmTemplateControl.cs:73)
HutongGames.PlayMaker.Fsm.CreateSubFsm (HutongGames.PlayMaker.FsmTemplateControl templateControl) (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:1460)
HutongGames.PlayMaker.Actions.RunFSM.Awake () (at Assets/PlayMaker/Actions/StateMachine/RunFSM.cs:33)
HutongGames.PlayMaker.Fsm.Awake () (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:1650)
HutongGames.PlayMaker.Fsm.Init (UnityEngine.MonoBehaviour component) (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:1677)
PlayMakerFSM.Init () (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/PlayMakerFSM.cs:248)
PlayMakerFSM.Awake () (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/PlayMakerFSM.cs:210)
Title: Re: Run FSM: InvalidCastException: Specified cast is not valid.
Post by: s0963123 on January 28, 2021, 09:20:57 PM
Sorry to bring up this old post. But I have very similar problem.
After setting up FSM Template with exposed variable, and run FSM.  The error log of "InvalidCastException: Specified cast is not valid." keep appear. And other game mechanism go wrongs as well.

I have already spent hours to troubleshoot it but in vain.
Roll back to a earlier version doesn't help either.

Could anyone point me in the right direction, on how to solve it? Or at least what goes wrong?

My unity version is 2019.1.14f1
My playmaker version is 1.9.0.p19

Quote
InvalidCastException: Specified cast is not valid.
HutongGames.PlayMaker.FsmVar.ApplyValueTo (HutongGames.PlayMaker.INamedVariable targetVariable) (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/FsmVariables/FsmVar.cs:674)
HutongGames.PlayMaker.FsmVarOverride.Apply (HutongGames.PlayMaker.FsmVariables variables) (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/CustomActionTypes/FsmVarOverride.cs:33)
HutongGames.PlayMaker.FsmTemplateControl.ApplyOverrides (HutongGames.PlayMaker.Fsm overrideFsm) (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/CustomActionTypes/FsmTemplateControl.cs:133)
HutongGames.PlayMaker.FsmTemplateControl.InstantiateFsm () (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/CustomActionTypes/FsmTemplateControl.cs:73)
HutongGames.PlayMaker.Fsm.CreateSubFsm (HutongGames.PlayMaker.FsmTemplateControl templateControl) (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:1460)
HutongGames.PlayMaker.Actions.RunFSM.Awake () (at Assets/PlayMaker/Actions/StateMachine/RunFSM.cs:33)
HutongGames.PlayMaker.Fsm.Awake () (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:1650)
HutongGames.PlayMaker.Fsm.Init (UnityEngine.MonoBehaviour component) (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:1677)
PlayMakerFSM.Init () (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/PlayMakerFSM.cs:255)
PlayMakerFSM.Awake () (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/PlayMakerFSM.cs:210)
Title: Re: Run FSM: InvalidCastException: Specified cast is not valid.
Post by: s0963123 on January 28, 2021, 10:04:50 PM
I finally manage to find out what goes wrong.

It appears to be some bug happened when you try to use a variable with the convert option in the variable pulldown menu in a 'Run FSM'.

Would it be fixed soon? Because it greatly hurdle how we could use template to streamline our production, which is one of the great features of playmaker.
Title: Re: Run FSM: InvalidCastException: Specified cast is not valid.
Post by: Alex Chouls on January 28, 2021, 10:26:10 PM
Have you tried it in 1.9.1p1?
Title: Re: Run FSM: InvalidCastException: Specified cast is not valid.
Post by: s0963123 on January 29, 2021, 11:19:52 PM
Still show the same error message in 1.9.1.p2.

Title: Re: Run FSM: InvalidCastException: Specified cast is not valid.
Post by: Alex Chouls on January 29, 2021, 11:23:56 PM
Ok, thanks for checking. I'll investigate.
Title: Re: Run FSM: InvalidCastException: Specified cast is not valid.
Post by: Alex Chouls on January 30, 2021, 06:16:06 PM
This should be fixed in 1.9.1p3 currently in beta.
I've sent you an invite to the beta group if you have a chance to test it.
Title: Re: Run FSM: InvalidCastException: Specified cast is not valid.
Post by: s0963123 on January 31, 2021, 11:33:38 PM
Thank you.

A bit off-topic:

I wonder how the output in the "run fsm" in version 1.9.1.p2 work?

It works really fine until I use "Next Frame Event" inside the template and change the value of certain variable(seems the type doesn't matter), then the output function seems to be broke down. No error message, but the host FSM just don't get the output variable.

Is it bug, or I misunderstand something?
Title: Re: Run FSM: InvalidCastException: Specified cast is not valid.
Post by: Alex Chouls on February 01, 2021, 12:47:05 PM
Can you share the template here and I'll take a look.
Title: Re: Run FSM: InvalidCastException: Specified cast is not valid.
Post by: s0963123 on February 01, 2021, 07:26:01 PM
Attached is the design of template.
The first state is only a next frame event.
And when you run this fsm, the debug log would get the correct output(which is 111), but the host FSM cannot get the output variable.
Title: Re: Run FSM: InvalidCastException: Specified cast is not valid.
Post by: Alex Chouls on February 02, 2021, 03:50:52 AM
Thanks! This will be fixed in p3. The output values were off by one frame...
Title: Re: Run FSM: InvalidCastException: Specified cast is not valid.
Post by: Alex Chouls on February 02, 2021, 01:09:31 PM
1.9.1p3 is now in beta and should fix both of the bugs in this thread. Let me know if you get a chance to try it.
Title: Re: Run FSM: InvalidCastException: Specified cast is not valid.
Post by: s0963123 on February 03, 2021, 09:05:05 PM
Good to know.
Thanks so much.
Title: Re: Run FSM: InvalidCastException: Specified cast is not valid.
Post by: s0963123 on February 07, 2021, 09:02:35 PM
I am currently in 1.9.1.p2. But in the Installation tab, it shows the latest version is 1.9.1.p2 instead of 1.9.1.p3.

Any ideas on what I'm doing wrong and how to update to 1.9.1.p3?

Thanks again.
Title: Re: Run FSM: InvalidCastException: Specified cast is not valid.
Post by: Alex Chouls on February 07, 2021, 09:37:23 PM
Did you update in the Asset Store?
Title: Re: Run FSM: InvalidCastException: Specified cast is not valid.
Post by: s0963123 on February 08, 2021, 06:22:23 AM
Try that and works. Thanks.
Title: Re: Run FSM: InvalidCastException: Specified cast is not valid.
Post by: s0963123 on February 25, 2021, 09:12:42 AM
I finally manage to find out what goes wrong.

It appears to be some bug happened when you try to use a variable with the convert option in the variable pulldown menu in a 'Run FSM'.

Would it be fixed soon? Because it greatly hurdle how we could use template to streamline our production, which is one of the great features of playmaker.

Sorry to bring up this post again.
I stumbled upon a very similar situation again.
When using a variable with the convert option in the output session of a "Run fsm", it gives the " InvalidCastException: Specified cast is not valid." warning again.

But using convert variable in input works just fine.
Would it be fixed in future updated as well?
Thank you.
Title: Re: Run FSM: InvalidCastException: Specified cast is not valid. [FIXED]
Post by: Alex Chouls on February 26, 2021, 02:04:12 AM
I think that is a bug in the Output UI letting you select the Convert sub menu. I don't think that's supported yet. But let me investigate...
Title: Re: Run FSM: InvalidCastException: Specified cast is not valid. [FIXED]
Post by: s0963123 on March 03, 2021, 03:58:05 AM
any update?
Title: Re: Run FSM: InvalidCastException: Specified cast is not valid. [FIXED]
Post by: Alex Chouls on March 03, 2021, 04:30:28 PM
Yes, I can confirm the UI should not have been showing the Convert menu for Output variables. It's fixed in the next update, release imminent.
Title: Re: Run FSM: InvalidCastException: Specified cast is not valid. [FIXED]
Post by: s0963123 on March 04, 2021, 10:13:34 PM
got it, thanks.