Handling of Scene Changes with Save/Load

Announcements, support questions, and discussion for Save System for Opsive Character Controllers.
Post Reply
jkaczmar
Posts: 8
Joined: Thu Jun 29, 2023 7:15 pm

Handling of Scene Changes with Save/Load

Post by jkaczmar »

I'm trying to determine how the Save file tracks which scene the player is on save. I'm using UCC/UIS/Quest Machine/Pixel Crushers Save as master saver with UIS/UCC save integrations. My setup is a Master Scene with Player/UI/Common components and then additively loaded scenes for game levels. I'm running the following test scenario:

1. Start game and automatically load Level 01 (works)
2. Travel to Level 02 using PlayMaker Pixel Crusher calls (unload additive Level 01/load additive Level 02) (works)
3. Save Game (works)
4. Travel to Level 01 using PlayMaker Pixel Crusher calls (unload additive Level 02/load additive Level 01) (works)
5. Load game (fails in that I remain in Level 01 when I had saved in Level 02)

Is there additional setup or coding that I need to do so that the Pixel Crusher save knows which scene I was in when I saved?

(BTW, the integration you built with all the Opsive stuff is great. I've tested all of it in single scenes and it works great and is easy to setup.)
User avatar
Tony Li
Posts: 22655
Joined: Thu Jul 18, 2013 1:27 pm

Re: Handling of Scene Changes with Save/Load

Post by Tony Li »

Hi,

By default, the save system assumes you're loading and using single scenes since most people do this and it's the easiest for people to set up.

It does have support for additive scene loading, but it usually requires a bit more work / manual management of scenes.

Here are three approaches you could use:

1. Save everything in your Master Scene as a prefab. You could save them individually or save the whole thing as one big prefab. Then don't use the Master Scene. Instead, add an instance of this prefab to every scene. Tick the Save System component's Save Current Scene checkbox, and let the save system handle scene changes in single scene mode.

2. Or mark everything in your Master Scene as Don't Destroy On Load. This takes it out of the whole "unload this scene when loading another single scene" process. Then treat Level 01, Level 02, etc., as single-scene loads. Tick the Save System's Save Current Scene checkbox, and let the save system handle it.

3. Or handle additive scenes. UNtick the Save System's Save Current Scene checkbox. Keep track of which scenes you've additively loaded and unloaded. You could save this in a Playmaker list. After loading a saved game, use the Save System's Playmaker action to load the additive scenes.
jkaczmar
Posts: 8
Joined: Thu Jun 29, 2023 7:15 pm

Re: Handling of Scene Changes with Save/Load

Post by jkaczmar »

Thanks for the quick response. This makes sense as I was going through the log. It looks like it tries to load the scene it was in which it views as the Master Scene since it's always floating around at the top. I've used the single scene with key prefabs in it (Player, UI, etc.) before and I wanted to try using the Master Scene approach but it sounds like more work with little added benefit.

I'll go back to the way I was doing it previously with individual scenes that have all the key prefabs. I'm not exactly doing open world, but it will be a handful of very large scenes so the cross-scene prefab management shouldn't be too burdensome.
User avatar
Tony Li
Posts: 22655
Joined: Thu Jul 18, 2013 1:27 pm

Re: Handling of Scene Changes with Save/Load

Post by Tony Li »

Sounds good! If you run into any issues, let me know.
Post Reply