Saving for Playmaker

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
nickg84
Posts: 23
Joined: Mon Sep 13, 2021 1:52 pm

Saving for Playmaker

Post by nickg84 »

Hello,

I'm currently working through the save features from Dialogue and Quest. I also use Top Down Engine with Inventory, as well as Playmaker pretty heavily. I downloaded the Menu Framework (which I've used before and love as a starting point).

Anyway, all that aside, I followed all the integration tutorials and, as of right now, I think it's all mostly working, but I haven't really tried to break it for bugs yet. One thing that isn't working as planned, however, is Playmaker. I've got that integration in, including the Global Variable Saver, so that's all working. But I noticed that loading a save state doesn't seem to load where an FSM was at the point of the save, nor does it reset the FSM. If I save a game, then load it from a different point, the FSM just tries to move to that state from it's current location in the FSM, wherever it's at.

I've got my FSMs set up pretty well when moving through scenes, so I know it's working when they're reset. Is there anyway to set up the save functions to reset FSMs when loading in or loading into the exact state at the point of save? Just for context, I'm mainly running into issues with a day/night cycle I created. I can save at night, reload the game during the day, then load that save, but the FSM gets stuck somewhere before the point of save (thus, lighting isn't loaded correctly, etc).

Hope that makes sense, haha.
User avatar
Tony Li
Posts: 23238
Joined: Thu Jul 18, 2013 1:27 pm

Re: Saving for Playmaker

Post by Tony Li »

Hi,

Out of the box, the Pixel Crusher save system doesn't save the states of FSMs.

As you've seen, you can save Playmaker global variables using PlayMakerGlobalVariableSaver.

If you need to save the states of FSMs, here are two options:

1. Write a custom saver script that saves the state of an FSM. (This requires some comfort with C#.)

2. Or, when saving, use global variables to record information about the current states of important FSMs. After loading a saved game, check the global variable values to put the FSMs into their proper states.
nickg84
Posts: 23
Joined: Mon Sep 13, 2021 1:52 pm

Re: Saving for Playmaker

Post by nickg84 »

Ok thanks. What I ended up doing was in the menu framework > LoadGamePanel > On Load Game, I have it function to reset the FSMs after a second or two, which seems to solve the issue.

One thing I just now discovered is that, after saving, the scenes are then saved in that state, and then revert to that saved state when switching scenes (not using the load game function). This only happens after I save the game. For example, I've got a clock (global variable), it's 4:00 when I save. If I walk through a scene portal at 5:00, the clock reverts back to 4:00 in the new scene. Any idea why this is happening?
User avatar
Tony Li
Posts: 23238
Joined: Thu Jul 18, 2013 1:27 pm

Re: Saving for Playmaker

Post by Tony Li »

Is the time a Playmaker global variable?
nickg84
Posts: 23
Joined: Mon Sep 13, 2021 1:52 pm

Re: Saving for Playmaker

Post by nickg84 »

Yes it is
User avatar
Tony Li
Posts: 23238
Joined: Thu Jul 18, 2013 1:27 pm

Re: Saving for Playmaker

Post by Tony Li »

That makes sense then. If there's a PlayMakerGlobalVariableSaver component, it will save and restore Playmaker global variable values.
Post Reply