playMaker

Author Topic: Whydoidoit-Unity Save Game / Level Serialization  (Read 19471 times)

Mark_T

  • 1.2 Beta
  • Junior Playmaker
  • *
  • Posts: 72
Whydoidoit-Unity Save Game / Level Serialization
« on: June 06, 2012, 03:16:13 PM »

What do you think about this ?
I`m not a programmer but some things I read there looked interesting to me.
I would love to hear the feedback of the more experienced playmakers, and of course, especially from the ones with programming feedback. :)
Thanks.


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Whydoidoit-Unity Save Game / Level Serialization
« Reply #1 on: June 06, 2012, 03:28:14 PM »
Hi,

 Due to the wrapped up nature of Fsm, states , actions and fsm variables, I don't think this kind of framework are suitable as is. because they actually go through the script itself to find what to serialize, and it won't be able to access a playmaker Fsm. It would require a specific implementation to understand and work with playmaker.

I would instead take level saving and loading in consideration right from the beginning of the thinking process to implement routines and patterns in each Fsm to account for this. that's a lot of work. IF Fsm could be saved as a xml, this would be trivial, I have been mentionning this several time actually, and this is actually going further, meaning saving a Fsm not just by its state during editing, but also taking a snapshot of it at runtime, and be able to load it back whenever and start from there. That would be quite good indeed, but would need to be something built in playmaker, not sure that it's possible to do that with the current playmaker api ( It might very well be tho)

 bye,

 Jean

Mark_T

  • 1.2 Beta
  • Junior Playmaker
  • *
  • Posts: 72
Re: Whydoidoit-Unity Save Game / Level Serialization
« Reply #2 on: June 06, 2012, 04:03:46 PM »
Aha, I understand. Or I think I understand.

Would it be possible to unwrap, or to expose, some of the "values" in Playmakers actions? Something like an option or a checkbox that needs to be clicked to expose a specific value, or a bool, etc.
Or maybe a Playmaker built-in addon?
Sorry if I`m talking rubbish. :)

It`s always a pleasure when I get some enlightenment in some of the darkest corners of my mind.
Many thanks Jean.


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Whydoidoit-Unity Save Game / Level Serialization
« Reply #3 on: June 07, 2012, 01:27:35 AM »
Hi,

 Not really, unless you are ready to rewrite ALL the actions you are going to use in that project...
 

 instead I would write actions to explictly serialize Fsm variables or for example the current state name of a fsm. and an action to get that when Fsm start or upeon a specific event and simply move to that state and set the variables. I think that path is possible, I even dare saying that one action could simply scan all variables of the fsm in one go to read of write against this framework, but not tested, just a guess.

 Bye,

 Jean

whydoidoit

  • Playmaker Newbie
  • *
  • Posts: 12
Re: Whydoidoit-Unity Save Game / Level Serialization
« Reply #4 on: June 08, 2012, 07:37:24 AM »
I'm a big fan of PlayMaker and have used it myself in a couple of projects.  I'd be happy to see if I could get PlayMaker scripts to store using my serializer - though I would imagine that there would be quite a lot of initialization to go through after deserializing.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Whydoidoit-Unity Save Game / Level Serialization
« Reply #5 on: June 08, 2012, 08:22:15 AM »
Hi,

 Well, For a given Fsm,it really only need to store the current state and the variables values, so I think the big effort will be in finding your way in the playmaker api to access them,

 I created a guiML system ( not yet release, just getting dusty in a corner of my hardrive, waiting for something...) that parse an xml file to create gui component on screen, tightly coupled with Fsm variables and events, even implementing multi bindings of variables. So I do have examples of api calls to get to variables of a fsm, etc etc. If you need help, I'll be very happy to work on that with you. I see a great potential in your solution.

 Bye,

 Jean

whydoidoit

  • Playmaker Newbie
  • *
  • Posts: 12
Re: Whydoidoit-Unity Save Game / Level Serialization
« Reply #6 on: June 11, 2012, 06:14:52 AM »
So I think I've got the variables sorted out - but I'm having a hard time forcing the FSM back into the state it was in when it saved.  ChangeState doesn't appear to do it (probably because the state isn't valid from the initialized state).  I could go and set the "active" on the FsmState (the private one) but that doesn't appear to change the Active state (the public one).

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Whydoidoit-Unity Save Game / Level Serialization
« Reply #7 on: June 11, 2012, 06:53:29 AM »
Hi,

 I don't know how to change state via the api, not even sure it's possible, but would be great. WIlling to know too :)

 I's suggest you open a new thread about this on the suggestion forum.

 bye,

 Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Whydoidoit-Unity Save Game / Level Serialization
« Reply #8 on: June 11, 2012, 08:44:05 AM »
Hi,

 one way to overcome this "switching" to state from api would be to declare a event for each state that can be serialized, and then the api will allow you to fire the event so that you can go to that state.

 I just did a small package showing how to use "send event" to move to a state without transition, from the api you woul dsimply call that event and it that would work.

http://hutonggames.com/playmakerforum/index.php?topic=1735.msg7626#msg7626

 Bye,

 Jean

whydoidoit

  • Playmaker Newbie
  • *
  • Posts: 12
Re: Whydoidoit-Unity Save Game / Level Serialization
« Reply #9 on: June 11, 2012, 04:29:25 PM »
Ok so I think it's working well now - at least the NoExit sample seems ok.  There may yet be bugs to find :)

I've published it as an add-in package to UnitySerializer - now FSMs attached to stored objects have their variables store - additionally the first one also stores the global variables and the states are activated on load.

Available from http://whydoidoit.com/unity-serializer-v0-2/

whydoidoit

  • Playmaker Newbie
  • *
  • Posts: 12
Re: Whydoidoit-Unity Save Game / Level Serialization
« Reply #10 on: June 19, 2012, 05:52:03 PM »
UnitySerializer is now available on the Asset Store and the PlayMaker extension is available from my website.

amaranth

  • Full Member
  • ***
  • Posts: 172
Re: Whydoidoit-Unity Save Game / Level Serialization
« Reply #11 on: August 17, 2012, 12:54:49 PM »
This came at just the right time. Thank you!

JustMeAgain

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Whydoidoit-Unity Save Game / Level Serialization
« Reply #12 on: September 24, 2012, 01:08:13 PM »
Hey, I'm new to using PlayMaker, and was looking at how to serialize an FSM with it's variables when I stumbled across your Unity Serializer. It works great!

I'm just messing around, trying to learn stuff, and was looking at how the Unity Serializer deserialized the active state, but when I try setting it using reflection in my own code, all of the actions in the active state fire every frame ( they aren't set to in in the action on the state).

Is there some initialisation step I'm missing when setting the active state via reflection?

this works fine in the Unity Serializer, I'm just trying to learn stuff :)

Thanks!

whydoidoit

  • Playmaker Newbie
  • *
  • Posts: 12
Re: Whydoidoit-Unity Save Game / Level Serialization
« Reply #13 on: October 03, 2012, 06:00:00 AM »
Sorry for the late reply - I have a bunch of threads on forums and I've neglected this one - you can report faults or ask for support on the forums on http://whydoidoit.com

I think I'd need to see some of your reflection code - I can't think of a particular step off hand...

FractalCore

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 100
Re: Whydoidoit-Unity Save Game / Level Serialization
« Reply #14 on: November 03, 2012, 11:03:00 AM »
I was just wondering where on your site is the download for the Playmaker plugin, I had a search and could only find it mentioned but no link.