Page 1 of 1
Save system issues
Posted: Tue May 09, 2023 2:48 pm
by Esylin
Hi,
I am trying to setup save system following the manual. I think I got the save and load buttons working. But my player character and camera, which has 'don't destroy on load' script attached, has duplicated copies after I load a save game.
How do I prevent this?
Re: Save system issues
Posted: Tue May 09, 2023 4:09 pm
by Tony Li
Hi,
Can you remove the Don't Destroy On Load scripts?
This is probably what's happening:
- Your scene has a player character (PC) GameObject and a camera GameObject.
- When the scene starts, the Don't Destroy On Load script moves the PC and camera into the special Don't Destroy On Load section.
- When you load a saved game, it destroys the old scene (but not the PC and camera) and loads a new copy of the scene, which contains a PC and camera. So now you have two of them.
If you remove the Don't Destroy On Load scripts, then when you load a saved game it will destroy the PC and camera and load them from the new copy of the scene. If you want saved info to pass along to the new instances of the PC and camera, add Saver components to them, and set unique keys. For example, if you want to save the player's position, add a Position Saver component and assign a unique Key value such as "playerPosition".
If you can't remove the Don't Destroy On Load scripts for some reason, you can UNtick the Save System component's Save Current Scene checkbox. This won't load a new copy of the scene, so you won't get double GameObjects. But, of course, it won't load a new copy of the scene, so it won't reset the scene (apart from savers) or load the scene that the player saved in if the player saved in a different scene.
Re: Save system issues
Posted: Wed May 10, 2023 8:39 am
by Esylin
Hello,
My player game object has Don't Destroy On Load script on because I am using Opsive Ultimate Inventory System, so the player game object carries an inventory and currency with them when they enter the next scene.
But I think I may have a solution without needing to remove the script. I'll create an empty starting scene(scene 1) with the player game object in it, but scene 1 doesn't allow the player to save nor load. After the game starts in scene 1 it immediately transfers the player game object to a real playable scene(scene 2) without player game object in it. Theoretically I think it should only load 1 player game object this way since the player can only save and load in scene 2 and onward?
I have 2 other questions about the save system and UIS integration since I can't find the answer on the manual ^^;
1) I am experimenting with UIS save system but I can't get UIS save system to work even with Pixel Crushers to UIS Saver script attached. UIS save system will save my inventory and currency data, but not dialogue manager database changes.
What else am I missing in the setup? My Dialogue Manager has Pixel Crushers to UIS Saver, PlayerPrefs Saved Game, Json Data Serializer, Dialogue system saver and Save system, UIS Lua components attached.
Using Dialogue System save system + UIS saver script seems to work fine, but not UIS save system + Pixel Crushers to UIS Saver script.
2) I created a save and load button using Save System Methods script similar to how the demo scene is setup(one save button and one for load) , but how can the player save to different slots for different progressions and still able to tell which save is which? How can I also save current time like in other games so players can tell that they are loading the correct file?
Re: Save system issues
Posted: Wed May 10, 2023 8:54 am
by Tony Li
Hi,
Esylin wrote: ↑Wed May 10, 2023 8:39 amMy player game object has Don't Destroy On Load script on because I am using Opsive Ultimate Inventory System, so the player game object carries an inventory and currency with them when they enter the next scene.
For UIS, the save system is designed for the player GameObject to
not be set to Don't Destroy On Load.
Instead, put a player GameObject in each scene,
not marked Don't Destroy On Load. Add saver components such as UIS Saver and Position Saver (or UCC Saver if you're using UCC).
Set up the save system. Change scenes using any of
these techniques. The save system will record the current scene player's UIS inventory to the save system's memory before leaving the old scene. After entering the new scene, the save system will restore the new scene player's UIS inventory to the state that was recorded in the save system's memory.
Esylin wrote: ↑Wed May 10, 2023 8:39 am2) I created a save and load button using Save System Methods script similar to how the demo scene is setup(one save button and one for load) , but how can the player save to different slots for different progressions and still able to tell which save is which? How can I also save current time like in other games so players can tell that they are loading the correct file?
To save to different slots, call SaveSystem.SaveToSlot(#) in C# code, or add a Save System Methods component to a UI Button and configure the Button's OnClick() event to call SaveSystemMethods.SaveToSlot. (The free menu framework available on the Dialogue System Extras page works this way.)
To save the current time, see:
How To: Include Summary Info In Saved Games
Re: Save system issues
Posted: Wed May 10, 2023 1:13 pm
by Esylin
Tony Li wrote: ↑Wed May 10, 2023 8:54 am
Instead, put a player GameObject in each scene,
not marked Don't Destroy On Load. Add saver components such as UIS Saver and Position Saver (or UCC Saver if you're using UCC).
Set up the save system. Change scenes using any of
these techniques. The save system will record the current scene player's UIS inventory to the save system's memory before leaving the old scene. After entering the new scene, the save system will restore the new scene player's UIS inventory to the state that was recorded in the save system's memory.
Thank you.
I got Scene change and inventory data working correctly now.
Tony Li wrote:(The free menu framework available on the Dialogue System Extras page works this way.)
To save the current time, see: How To: Include Summary Info In Saved Games
Thanks! I'll try these methods!
Re: Save system issues
Posted: Wed May 10, 2023 2:01 pm
by Tony Li
Glad to help!