Trouble with saving

Announcements, support questions, and discussion for Quest Machine.
cptscrimshaw
Posts: 113
Joined: Sun Sep 20, 2020 8:21 pm

Re: Trouble with saving

Post by cptscrimshaw »

Thanks Tony - all of these answers were super helpful. I have one last thing I'm stuck on.

I keep getting a (Last Check: False) on my Dialogue System Trigger. I've included screenshots of my setup.

The quest is showing active in my Player Journal, I have a stub set up in the Dialogue System Quests/Items tab, I triple checked I had the Quest ID spelled correctly, so I'm at a loss.

https://ibb.co/1X545fr
https://ibb.co/NNbPJFq
https://ibb.co/thbLFcy
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: Trouble with saving

Post by Tony Li »

Hi,

While playing, go to the Dialogue Editor's Watches tab. Select Menu > Add Watch. Then enter the Lua condition and click Refresh. Does it return true or false?

Does your Dialogue Manager have a Dialogue System Quest Machine Bridge component?

Are any other conditions lurking inside Quest Conditions, Accepted Tags or Accepted GameObjects?
cptscrimshaw
Posts: 113
Joined: Sun Sep 20, 2020 8:21 pm

Re: Trouble with saving

Post by cptscrimshaw »

Watch returns true. Bridge component is there. Nothing else in the Dialogue System Trigger.

Tried reloading the game and entering a new scene just to make sure On Start was called and no luck.

I did narrow it down, though. I set the dialogue system trigger to "On Trigger Enter" and put a box collider 2d component with a trigger on it and that worked! So something with the On Start isn't working...

Narrowed it down even further. Put a Timed Event to activate the gameobject that the On Start dialogue system trigger is on after 1 frame. And that worked.

Anything else to try?

https://ibb.co/XYM4rMj
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: Trouble with saving

Post by Tony Li »

Thanks for the info. Keep the Timed Event.

I can explain what's happening.

When you load a saved game, the save system waits a number of frames before actually applying the saved game data. If any other components, such as character controllers, initialize themselves in Start(), this gives them the necessary time to initialize before receiving the saved game data.

However, if the Dialogue System Trigger runs immediately OnStart, then the quest states won't have been restored yet from the saved game data. By using the Timed Event component, you give the save system enough time to restore the quest states first.

If no other components need time to initialize themselves, you could set the Save System's 'Frames To Wait Before Apply Data' to zero. Then the quest states will be restored as soon as the scene is loaded, and the Dialogue System Trigger's OnStart can work right away.

UCC's inventory, however, initializes its default loadout in Start(). You must wait one frame. Otherwise the save system will restore the saved loadout, and then the inventory's Start() method will initialize it back to the default loadout. Since you're using UCC, you should set 'Frames To Wait Before Apply Data' to 1 and use the Timed Event.
cptscrimshaw
Posts: 113
Joined: Sun Sep 20, 2020 8:21 pm

Re: Trouble with saving

Post by cptscrimshaw »

Thanks again Tony.

I noticed that my Dialogue System variables weren't saving between loads (verified through watches), and I realized I didn't have a Dialogue System Saver component anywhere. So I added that to my Pixel Crushers Save System gameobject that includes all the other save components.

When I play the game, I get the following console error (game runs fine, but it still doesn't save my DS variables when I exit play and enter play mode again):

Dialogue System: Lua code '{"m_DateTimeTicks":637374272733949430,"m_SaveDataKeys":["Game_Opsive.UltimateInventorySystem.SaveSystem.InventorySystemManagerItemSaver_","Player_Opsive.UltimateInventorySystem.SaveSystem.InventorySaver_","Storage Chest_Opsive.UltimateInventorySystem.SaveSystem.InventorySaver_"],"m_SerializedSaveData":[{"m_ObjectType":"Opsive.UltimateInventorySystem.SaveSystem.InventorySystemManagerItemSaver+ItemsSaveData","m_ValueHashes":[1606553928,1747267347,704049074,-1539243910,120360732,1650266376,-336450385,-648531920,1747267300,703944785,-1539131495,120535295

Any idea what I'm missing or have configured incorrectly?

Images of setup:
https://ibb.co/wSTs8tk
https://ibb.co/8NknMKB
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: Trouble with saving

Post by Tony Li »

Hi,

Assign unique keys to each saver (Dialogue System Saver and UIS Saver). Otherwise they'll both save their data under a default key value that uses the GameObject name. Since they're on the same GameObject, this means they're overwriting each other.
cptscrimshaw
Posts: 113
Joined: Sun Sep 20, 2020 8:21 pm

Re: Trouble with saving

Post by cptscrimshaw »

Thank you! As always, super simple solution.
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: Trouble with saving

Post by Tony Li »

Happy to help!
cptscrimshaw
Posts: 113
Joined: Sun Sep 20, 2020 8:21 pm

Re: Trouble with saving

Post by cptscrimshaw »

I am hoping to set up additive scene loading for my game (which is incorporating the Dialogue System, Quest Machine, and UIS) mostly because I'd like to have a persistent scene that includes all of the core elements rather than adding them to every scene.

After reading through the forum, it seems like this is an option with the Save System, but I couldn't find any detailed info on the best way to set it up. I have everything working regarding saving with two scenes, but I just have all the key gameobjects in both scenes, so it works fine.

Any general tips or where I could start researching to get started on this? I know how to add scenes additively, just not sure how to do that and also use the pixel crushers save system.
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: Trouble with saving

Post by Tony Li »

Hi,

Instead of SceneManager.LoadScene("scene", LoadSceneMode.Additive), use PixelCrushers.SaveSystem.LoadAdditiveScene("scene"). Unload it using PixelCrushers.SaveSystem.UnloadAdditiveScene("scene"). If you want to unload all additively-loaded scenes, use UnloadAllAdditiveScenes().

This incorporates the save system into the additive load/unload process.
Post Reply