playMaker

Author Topic: Restore FSM State / Save FSMs and load when loading scene  (Read 12783 times)

haikugames

  • Playmaker Newbie
  • *
  • Posts: 25
Restore FSM State / Save FSMs and load when loading scene
« on: June 30, 2015, 12:07:41 PM »
I have an adventure game made in Playmaker. In the game I have a lot of FSMs which represent objects the player can interact with.  For example, I have a Sprite with a PlaymakerFSM which is a box.  It starts unopened, and then when the player taps on it, I change the Sprite to a box open sprite with an item inside, and when the player taps again the item is taken.  My FSM represents each of these states.

Right now, we just save when the player has completed the entire scene (we just keep a Int in PlayerPrefs to note how many levels the player has completed). Ideally, we will save the progress of the player every time he takes an action, so if he does not complete the whole scene, he can return to it later.

My question is what's the best way to save all this.  I want the player to be able to load the level and see all the objects in the state s/he left them in (so if they opened the box but didn't take the item, it looks like that).  As far as I can tell, it's hard to load FSMs in an intermediate state. 

We're looking for advice here, but if someone knows how to do this we are also hiring a contractor to implement the system for our project:
https://www.upwork.com/jobs/Save-and-Restore-Intermediate-FSM-States-Playmaker_~017f41263674437436

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7614
    • jinxtergames
Re: Restore FSM State / Save FSMs and load when loading scene
« Reply #1 on: June 30, 2015, 12:37:02 PM »
easy save 2 (asset not free) has a save all action witch saves all global variables and / or fsm variables
and an action to load all.

if used with only fsm variables it will save only the variables inside that fsm which can be useful

another way is maybe to use (free) ArrayMaker or DataMaker (xml)
which can be easier to use when prefabs are used.

haikugames

  • Playmaker Newbie
  • *
  • Posts: 25
Re: Restore FSM State / Save FSMs and load when loading scene
« Reply #2 on: June 30, 2015, 03:18:12 PM »
Thanks for replying. I understand I can use EasySave to save all FSM variables, but that still won't let me restore the state I am in.  Let's say I have 3 states.

1) Box Unopened (start state), 2) Box Opened, 3) Item taken from box.

Let's say the player is in State #2.  If I use EasySave, I can save the variables of State #2.  However, when I load, Playmaker still thinks that I am in State 1 because that is the start state.  That's troublesome because I want the player to be able to tap and go from State #2 to State #3.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Restore FSM State / Save FSMs and load when loading scene
« Reply #3 on: June 30, 2015, 03:27:48 PM »
Hi,

There isn't any easy solution for this atm. But I guess there is a potential small system to create that could simply save the current state and force an fsm to enter that state on demand. I have created a system that is synchronized with Unity Mecanim states, so I guess I can work something out of this for that purpose.

 Can you bump me towards the end of the week if nothing comes up from me on this thread?

Bye,

 Jean

haikugames

  • Playmaker Newbie
  • *
  • Posts: 25
Re: Restore FSM State / Save FSMs and load when loading scene
« Reply #4 on: June 30, 2015, 04:29:58 PM »
That sounds great. I can't say enough about Playmaker - it allowed us to create our entire project.  It's very baked into our project, so we just want to be able to go back and add save states.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7614
    • jinxtergames
Re: Restore FSM State / Save FSMs and load when loading scene
« Reply #5 on: June 30, 2015, 05:00:48 PM »
the way you could do is make an int, set default 1. when box is opened set to 2, when item is taken set to 3 and save

on start state load the int before the other actions, then do an int switch
if 2 go to state 2 , 3 go to state 3

you can do this with playerprefs also

haikugames

  • Playmaker Newbie
  • *
  • Posts: 25
Re: Restore FSM State / Save FSMs and load when loading scene
« Reply #6 on: July 06, 2015, 01:03:37 AM »
Hi Jean, I wanted to bump you about the possibility of some way to restore FSM states.

@djaydino, I thought of that as a strategy.  The reason I didn't want to go with that is if I have a FSM with 20 or 30 states, I will need to have 20 or 30 separate events to restore each state.  Since we have many FSMs in each scene, it seems like it will be an overwhelming amount of manual work which is very error prone.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7614
    • jinxtergames
Re: Restore FSM State / Save FSMs and load when loading scene
« Reply #7 on: July 06, 2015, 08:28:15 AM »
Hi,
i do not know how you fsm's are setup,
but i think you do not need to connect to each state, only @ key points.

but it would ofc be easier if you could save all current states and get them back in on loading.

i might take a while (jean is a very busy man)

but keep on bumping.

haikugames

  • Playmaker Newbie
  • *
  • Posts: 25
Re: Restore FSM State / Save FSMs and load when loading scene
« Reply #8 on: July 09, 2015, 09:33:07 PM »
Thanks Dino :)

Thyriax

  • Playmaker Newbie
  • *
  • Posts: 25
    • Torii games
Re: Restore FSM State / Save FSMs and load when loading scene
« Reply #9 on: July 10, 2015, 02:47:45 AM »
Hi,
Maybe, you could work with Array Maker and use "Array list send event to game object"?
Or use "Exists" action to compare a saved variable within a gameobjet?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Restore FSM State / Save FSMs and load when loading scene
« Reply #10 on: July 15, 2015, 12:39:31 PM »
Hi,

 I am indeed interesting in this topic, so please bump me, get back to me end of august. I know that I won't be able to look at this before then, but I do want to do something for state restore, it's not difficult but needs to be done right.


Bye,

 Jean

Nimred

  • Playmaker Newbie
  • *
  • Posts: 4
    • Timecraft Games
Re: Restore FSM State / Save FSMs and load when loading scene
« Reply #11 on: July 26, 2015, 02:10:06 PM »
Hi,

I just wanted to say that I have pretty much the same need as haikugames. My game uses lots of state machines to drive the story (one per narrative "scene") and when the player takes action and moves the story along, the state changes accordingly.

I need to be able to save which state the player is in, and restore to that state next time the game is started. I tried to set the ActiveState on the Fsm, but unfortunately that's not accessible.

I would also like to be able to set an FSM back to its starting state, without having to call enable/disable. Both problems could possibly be solved if the active state could be changed by script...

I hope you can find time for this soon :)

Michael
« Last Edit: July 26, 2015, 02:11:44 PM by Nimred »

haikugames

  • Playmaker Newbie
  • *
  • Posts: 25
Re: Restore FSM State / Save FSMs and load when loading scene
« Reply #12 on: August 13, 2015, 07:18:03 PM »
I wanted to bump this as we are in August now.   :)

haikugames

  • Playmaker Newbie
  • *
  • Posts: 25
Re: Restore FSM State / Save FSMs and load when loading scene
« Reply #13 on: August 28, 2015, 05:03:05 PM »
Another bump :)

Nimred - if you found another solution let us know please! Thanks

haikugames

  • Playmaker Newbie
  • *
  • Posts: 25
Re: Restore FSM State / Save FSMs and load when loading scene
« Reply #14 on: September 05, 2015, 08:43:08 PM »
Still very much interested in this :)