Saving between scenes.

Announcements, support questions, and discussion for Quest Machine.
om3n
Posts: 19
Joined: Mon Jan 31, 2022 8:29 am

Saving between scenes.

Post by om3n »

Everything seems to be working in scene, however if I transition to another scene and back again right away it seems the quest states are lost. Everything else saves like position etc, even through closing and re-opening the game. Just seems like it's only the quests that seem to get lost between scenes, otherwise works great if you don't leave the scene. Seems strange because the rest of the save seems to work flawlessly in between scenes.

Edit: Ok I'm doing something wrong I'm sure. Also notice my inventory isn't saving between scenes as well. Just player position.
User avatar
Tony Li
Posts: 21926
Joined: Thu Jul 18, 2013 1:27 pm

Re: Saving between scenes.

Post by Tony Li »

Hi,

Have you set up the save system? If so, are you changing scenes using any of the methods listed here? (That's a Dialogue System link. If you're not using the Dialogue System, all of the methods still apply to Quest Machine except the first one.)

Make sure the player's Quest Journal component has an Save Key that's unique in the scene (e.g., "playerJournal" or something) and that the player's Quest Journal components across all scenes use the same Save Key.

For your inventory, please remind me if you're using an inventory asset such as Opsive Ultimate Inventory System, More Mountains' Inventory Engine, or Invector's inventory. If so, they all have inventory saver components. Make sure they're also set up like I described above.
om3n
Posts: 19
Joined: Mon Jan 31, 2022 8:29 am

Re: Saving between scenes.

Post by om3n »

HI,

I assume it's setup. the player position is working if I go to another scene and close the game then load it back up. It loads into the other scene. I have enabled persistence on the inventory objects using the more mountains inventory. I'm using Both your plugins. So If I start game in editor, transition to another scene and shut it off and restart editor play I am back where I shut it down.

I was using moremountains GoToLevelEntryPoint, but trying the Scene Portal gave the same result. The player's prefab has a unique key setup and since it's an instantiated object, this shouldn't change.
User avatar
Tony Li
Posts: 21926
Joined: Thu Jul 18, 2013 1:27 pm

Re: Saving between scenes.

Post by Tony Li »

More Mountains' character persistence may be saving the player's position. What More Mountains asset(s) are you using?

You may need to add a SaveSystemTopDownEventListener component, for example to the Quest Machine GameObject, to tie it into MM's persistence/save system. Tick the component's Handle MM Save Load Events.
om3n
Posts: 19
Joined: Mon Jan 31, 2022 8:29 am

Re: Saving between scenes.

Post by om3n »

Tony Li wrote: Wed Feb 02, 2022 11:03 am More Mountains' character persistence may be saving the player's position. What More Mountains asset(s) are you using?

You may need to add a SaveSystemTopDownEventListener component, for example to the Quest Machine GameObject, to tie it into MM's persistence/save system. Tick the component's Handle MM Save Load Events.
Not really sure about which asset, but the saving didn't happen until i implemented the saving scripts from the pixel crushers and the position script on the player.
User avatar
Tony Li
Posts: 21926
Joined: Thu Jul 18, 2013 1:27 pm

Re: Saving between scenes.

Post by Tony Li »

Sorry, I was unclear. Are you using Corgi Platformer Engine? TopDown Engine? Or only Inventory Engine by itself, without Corgi or TopDown?
om3n
Posts: 19
Joined: Mon Jan 31, 2022 8:29 am

Re: Saving between scenes.

Post by om3n »

Tony Li wrote: Wed Feb 02, 2022 11:47 am Sorry, I was unclear. Are you using Corgi Platformer Engine? TopDown Engine? Or only Inventory Engine by itself, without Corgi or TopDown?
sorry for the quoting, it tries to use my last post for some reason and I'm too tired to figure it out. I'm using TDE with quest machine and dialogue.
User avatar
Tony Li
Posts: 21926
Joined: Thu Jul 18, 2013 1:27 pm

Re: Saving between scenes.

Post by Tony Li »

Got it. Set up the save system. Here are some steps:

1. Add a Save System component to the Quest Machine GameObject (or Dialogue Manager GameObject if you prefer). Untick 'Save Current Scene' since TDE's save system should handle keeping track of what scene to load when loading saved games.

2. Add Json Data Serializer and PlayerPrefs Saved Game Data Storer components to the Quest Machine GameObject (or Dialogue Manager). (PlayerPrefs Saved Game Data Storer isn't used in this case, but it silences a warning.)

3. Make sure no other GameObjects have the Save System component.

4. Assign a unique Save Settings > Save Key value to the player prefab's Quest Journal component.

To tie it into TDE's save system, add a SaveSystemTopDownEventListener component to the Quest Machine or Dialogue Manager GameObject.
om3n
Posts: 19
Joined: Mon Jan 31, 2022 8:29 am

Re: Saving between scenes.

Post by om3n »

Tony Li wrote: Wed Feb 02, 2022 3:02 pm Got it. Set up the save system. Here are some steps:

1. Add a Save System component to the Quest Machine GameObject (or Dialogue Manager GameObject if you prefer). Untick 'Save Current Scene' since TDE's save system should handle keeping track of what scene to load when loading saved games.

2. Add Json Data Serializer and PlayerPrefs Saved Game Data Storer components to the Quest Machine GameObject (or Dialogue Manager). (PlayerPrefs Saved Game Data Storer isn't used in this case, but it silences a warning.)

3. Make sure no other GameObjects have the Save System component.

4. Assign a unique Save Settings > Save Key value to the player prefab's Quest Journal component.

To tie it into TDE's save system, add a SaveSystemTopDownEventListener component to the Quest Machine or Dialogue Manager GameObject.
So to be sure I understand correctly. You want me to remove my save system prefab and move all the scripts I setup to the dialogue or the quest prefab. Then setup the moremountains save system, then integrate that into the other save system? It sounds a little on the complicated side. I mean I can easily move all the working stuff I setup from your system or delete it and start over, but it's working aside from quests and inventory so it seems redundant.

What I did (no saving whatsoever beforehand):
1) Setup a SaveSystem component in my managers. Added Auto Save load, Disk saved Game Data Storer, Save System, Spawned object manager with player prefab, a dont destroy gameobject, and Json Data Storer.
2) Added a Position Saver component to player. Tried to play around with multi enabled saver etc in experimenting blindly.
3) Verified Position was saved and loaded automatically.
4) Wondered what was needed to save and load quests and inventory.

There was no moremountains saving setup on my part. I'm not really sure where to begin. The inventory has a component for persistence, but does nothing. Even if I add the top down event listener to my save object it does nothing.
User avatar
Tony Li
Posts: 21926
Joined: Thu Jul 18, 2013 1:27 pm

Re: Saving between scenes.

Post by Tony Li »

I didn't realize you already had a Save System prefab instance in your scene. That simplifies things. Skip steps #1 - #3 and use your Save System prefab instance instead. They important thing is that there should only be one Save System component in the scene; otherwise they'll clobber each other. Since there should only be one Save System component in the scene, if there's also one on the Quest Machine GameObject, for example, it will try to destroy one of the GameObjects. This means it could destroy the Quest Machine GameObject, which would cause Quest Machine to fail.

The steps I provided above assume you're managing saves and loads through More Mountains by calling the MMSaveLoadManager's Save & Load methods in a custom C# script that you've written. They tie the QM/DS save info into More Mountains' save data. MMSaveLoadManager.Save() gathers save data from various sources, including QM & DS using the SaveSystemTopDownEventListener component, and then saves it. In this scenario, the More Mountains save system is the primary save system, and QM/DS provide save data to it.
Post Reply