Save Scale

Announcements, support questions, and discussion for Save System for Opsive Character Controllers.
Fearinhell
Posts: 44
Joined: Sun Feb 20, 2022 5:53 pm

Re: Save Scale

Post by Fearinhell »

Ill have to make a spreadsheet and figure out what needs saved across scenes. For me it will be this scale saver and some items. Thank you for explaining this!
Fearinhell
Posts: 44
Joined: Sun Feb 20, 2022 5:53 pm

Re: Save Scale

Post by Fearinhell »

Quick question, So lets say Scene 1 has Potions that need to be active state saved. I have created a MultiActiveSaver and have quite a few objects on it. It is attached to the player avatar so that as the character advances to scene 2 other items are saved for scene 2. BUT these potions are not in scene 2, will this cause an issue?
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: Save Scale

Post by Tony Li »

Yes. Use separate MultiActiveSavers in each scene. So scene 1's MultiActiveSaver saves the active states of the potions in scene 1, and scene 2's MultiActiveSaver saves the active states of the potions in scene 2.
Fearinhell
Posts: 44
Joined: Sun Feb 20, 2022 5:53 pm

Re: Save Scale

Post by Fearinhell »

So Im using the UCC Saver and it is stored on the parent object of the player character. When the player goes from scene 1 to scene 2 and a save is done the player still starts back in scene 1. I am doing a ASync load and moving the parent object and the player character to scene 2. How can I make the player start in scene 2 when they save in scene 2?
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: Save Scale

Post by Tony Li »

Hi,

1. Use a different player GameObject in each scene. (This isn't absolutely required, but it makes it easier to test scenes individually.)

2. Change scenes using PixelCrushers.SaveSystem.LoadScene() in C#, or use a ScenePortal component/prefab, or add a SaveSystemMethods component to some GameObject and configure a UnityEvent to call SaveSystemMethods.LoadScene.

Note that you can specify a spawnpoint by name in the destination scene. The Save System will look for a GameObject with that name and move the player there.
Fearinhell
Posts: 44
Joined: Sun Feb 20, 2022 5:53 pm

Re: Save Scale

Post by Fearinhell »

Between my scenes 1 and 2 I cant make a seperate game object, just too many variables and game objects in that tree that is required for my game.

Im using a scene transition asset for changing scenes that I really like so I guess Im going to try the save system methods component. I have attached that to the player character, do I need to put in a default starting scene name? I will just change my code in the load/continue button in menu to load. I guess my question is SaveSystemMethods will save the scene the character is in? Thanks Tony!
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: Save Scale

Post by Tony Li »

To change scenes using a different scene-changing asset, see the instructions in: How To: Change Scenes With Save System
Fearinhell
Posts: 44
Joined: Sun Feb 20, 2022 5:53 pm

Re: Save Scale

Post by Fearinhell »

Perfect! Thank you! Ill do some more reading and get this implemented.
Fearinhell
Posts: 44
Joined: Sun Feb 20, 2022 5:53 pm

Re: Save Scale

Post by Fearinhell »

Ok lets say I have added the correct code for saving. *Might need some more tweeking. I have a game menu and a Load Game function. Also lets say scenes 1 2 and 3. The player exits at scene 2 and that saves the game to slot 0. My code looks like

public void LoadGame()
{
SaveSystem.LoadFromSlot(0);
PixelCrushers.SaveSystem.ApplySavedGameData();
//SaveSystem.LoadScene("scene");
}

So if I use the savesystem.loadscene how does it know which of the 3 scenes to load from?
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: Save Scale

Post by Tony Li »

Hi,

Keep the Save System component's Save Current Scene checkbox ticked.

To save your game, just use:

Code: Select all

PixelCrushers.SaveSystem.SaveToSlot(0);
To load your game, just use:

Code: Select all

PixelCrushers.SaveSystem.LoadFromSlot(0);
If you were to use the Save System's scene changer, you'd use a Scene Portal or this code:

Code: Select all

PixelCrushers.SaveSystem.LoadScene("scene-name");
However, since you're using something else to change scenes, run this code before changing the scene:

Code: Select all

PixelCrushers.SaveSystem.RecordSavedGameData();
PixelCrushers.SaveSystem.BeforeSceneChange();
Then change the scene. After changing the scene, run this code:

Code: Select all

PixelCrushers.SaveSystem.ApplySavedGameData();
Post Reply