playMaker

Author Topic: Problems setting variables on FSMs via a custom inspector on prefabs  (Read 2061 times)

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Problems setting variables on FSMs via a custom inspector on prefabs
« Reply #15 on: May 23, 2023, 07:03:36 AM »
Hi.
@cheese_block

are you changing values during playmode when the objects get deleted (after stopping the game)?

Do you also get Stack Error?

cheese_block

  • Playmaker Newbie
  • *
  • Posts: 15
Re: Problems setting variables on FSMs via a custom inspector on prefabs
« Reply #16 on: May 24, 2023, 12:49:20 PM »
I've got it down to these steps:

Expand the additive scene
Select the gameobject with the FSM and scroll down to it
Hit Edit to open the Playmaker editor (this is a necessary step - the FSM needs to be showing)
Hit Play, then stop
Particular gameobjects will disappear from the additive scene

I've not been able to narrow down the problem any further. It only happens when using multiple scenes. I've tried deleting the Library folder. The FSM is quite complex. If I delete some of the objects from the main scene (seems to be those with prefabs) - then the issue disappears.

Not changing variables during playmode and no stack error.

cheese_block

  • Playmaker Newbie
  • *
  • Posts: 15
Re: Problems setting variables on FSMs via a custom inspector on prefabs
« Reply #17 on: May 25, 2023, 04:38:38 AM »
The problem has disappeared! I deleted everything out of one of the complex FSMs - the problem disappeared - then I reverted the FSM back and the problem didn't come back. Not sure what's going on.

Unfortunately although the problem has gone away - my variable setting custom inspector now no longer works - which is also odd.

@djaydino - with your editor window - how do you set the variables back to your FSMs? I'm going through the NamedVariables - setting their RawValue. Then I setDirty on the FSM gameobject. Is there anything else I should consider?

Thanks

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Problems setting variables on FSMs via a custom inspector on prefabs
« Reply #18 on: May 25, 2023, 05:24:39 AM »
Hi.
I am not setting fsmvalues directly.

I have created scriptable objects and Actions to get values from it :)
and the scriptable objects I have connected in editor.

for example if I spawn an enemy It will first get all data from the scriptable and place it in fsm variables or array lists.

Unfortunately although the problem has gone away - my variable setting custom inspector now no longer works - which is also odd.
Maybe references got lost?

cheese_block

  • Playmaker Newbie
  • *
  • Posts: 15
Re: Problems setting variables on FSMs via a custom inspector on prefabs
« Reply #19 on: May 25, 2023, 06:21:53 AM »
>Maybe references got lost?
The script does change the variables in the FSM - but they get reset on play.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Problems setting variables on FSMs via a custom inspector on prefabs
« Reply #20 on: May 28, 2023, 02:17:35 PM »
Oh wow, this is amazing. I can definitely see why and I wished I had the knowledge to setup something like this. Any place where I could start learning about it that you recommend?
First I started to learn to make custom actions for PM, then I started making tutorial videos about PM.
and people started to ask sample from those tutorials and said they would be willing to pay for it.
So I Made a asset for the asset store, so that they could easily get the sample.

but since most where beginners, they had issues exporting and getting custom actions.

so i started to experiment with editor scripts, so that when the Ecosystem was not installed it would open the url.
and if they have it, you can select missing actions and it would automatically open the Ecosystem and do the search. (so people could get familiar with the Ecosystem)

later on I started to experiment with scriptable objects for data, as you can make changes while in play mode and they would not be reverted when you stop the game.

But not so convenient to edited (finding/selecting the scriptable in the project window, then finding/editing the value inside the scriptable)

so i started to make a editor window, which grew quite a lot over the years as its very convenient (for our game)

for the basics I think you should be able to get something simple with Chat gpt.
you can also find some tutorial here and on youtube on scriptable objects

cheese_block

  • Playmaker Newbie
  • *
  • Posts: 15
Re: Problems setting variables on FSMs via a custom inspector on prefabs
« Reply #21 on: May 30, 2023, 05:34:46 AM »
I'm still having this problem with playmaker - where variables changed via a script get reset on play. Though it still might be something I'm doing wrong - it feels like it might be a bug in playmaker.

I've created a simple reproduction project - would be ok to post to the forums? would anyone be able to take a look?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Problems setting variables on FSMs via a custom inspector on prefabs
« Reply #22 on: May 30, 2023, 12:46:43 PM »
Hi.
You can share your projects, as long as the playmaker dll files are not included
Also it should not include other 3rd party assets that are not free

cheese_block

  • Playmaker Newbie
  • *
  • Posts: 15
Re: Problems setting variables on FSMs via a custom inspector on prefabs
« Reply #23 on: May 31, 2023, 02:56:12 AM »
Here's the test project:

https://drive.google.com/file/d/1VKiArQFVk1P1NsvPMtuC0H9al1mebY0-/view?usp=share_link

And here's the repo steps:

- Open the samplescene
- Select the FSM Variable Setter object
- Drag the FSM gameobject into the FSM slot (though it should be hooked up already)
- Change the text in the Test inspector field (no need to hit the button)
- Click on FSM gameobject- the text in the Test variable should have changed
- Hit play - the test variable should change back

I've added a Save to FSM button - this has some calls I've added to try and fix the problem - none seem to work. If someone wouldn't mind trying to replicate the problem. I appreciate any thoughts/ideas and whether this feels like a bug - or something wrong I'm doing.

Thanks


Christoph

  • Beta Group
  • Sr. Member
  • *
  • Posts: 254
Re: Problems setting variables on FSMs via a custom inspector on prefabs
« Reply #24 on: May 31, 2023, 11:33:33 PM »
Stupid comment but have you asked chatGPT for the reason why it’s not working and how to fix it? Might give you a complete new perspective.

cheese_block

  • Playmaker Newbie
  • *
  • Posts: 15
Re: Problems setting variables on FSMs via a custom inspector on prefabs
« Reply #25 on: June 01, 2023, 03:55:37 AM »
Not a stupid comment! I've been using ChatGPT quite a bit. It's given me some ideas - but nothing useful unfortunately. Been interesting to try using it - it generates some interesting replies - but sometimes it just completely makes up functions that don't exist!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Problems setting variables on FSMs via a custom inspector on prefabs
« Reply #26 on: June 01, 2023, 05:15:09 AM »
hi.
yea chat gpt works well but you need to ask the right questions.
also if there are no references to be found it will not find an answer.

I will ping Alex, maybe he can help out.

cheese_block

  • Playmaker Newbie
  • *
  • Posts: 15
Re: Problems setting variables on FSMs via a custom inspector on prefabs
« Reply #27 on: June 01, 2023, 06:11:54 AM »
Thanks very much

cheese_block

  • Playmaker Newbie
  • *
  • Posts: 15
Re: Problems setting variables on FSMs via a custom inspector on prefabs
« Reply #28 on: June 06, 2023, 06:05:45 AM »
Anyone had a chance to take a look at the repro project? thanks

cheese_block

  • Playmaker Newbie
  • *
  • Posts: 15
Re: Problems setting variables on FSMs via a custom inspector on prefabs
« Reply #29 on: August 29, 2023, 01:45:10 AM »
Just to finish this thread - turns out it was in my code not playmaker - I needed to use Undo.RecordObject - which I did try previously - but specifically I needed to pass through the FSM component.