Playmaker Forum
Bug Reporting => PlayMaker Bug Reporting => Topic started 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.
-
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?
-
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:
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)
-
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
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)
-
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.
-
Have you tried it in 1.9.1p1?
-
Still show the same error message in 1.9.1.p2.
-
Ok, thanks for checking. I'll investigate.
-
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.
-
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?
-
Can you share the template here and I'll take a look.
-
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.
-
Thanks! This will be fixed in p3. The output values were off by one frame...
-
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.
-
Good to know.
Thanks so much.
-
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.
-
Did you update in the Asset Store?
-
Try that and works. Thanks.
-
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.
-
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...
-
any update?
-
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.
-
got it, thanks.