Error in Checkpoints betwen Scenes

I am getting errors when I use the portal to change scenes saying the SavingWrapper has been destroyed but you are still trying to access it and a second error related to going back through the portal again.

It’s the image of the two errors that I am receiving when trying to implement save and load on the portal. Also here is a link to my Portal.cs script. Other than the Odin Inspector settings in it, I believe it is the same as Sam’s code he is working with.

Portal.cs -


Apologies its taken a little while to get to this question as Brian is away until Monday so i have been watching over the courses in his absence.
It sounds like that either the savingwrapper is being destroy and is not set to DontDestroyOnLoad so it may not be in the portal code that the issue is occuring.
I would compare our project to yours as you can download it from the resources and see if you can spot the issue thats causing that savingwrapper to not exist.

Let us know how you get on as Brian will be back on Monday and apologies for my lack knowledge as its been a long time since i was in the RPG code (I guess i need to rerun the course to refresh!)

The tricky part about this error is that it’s VERY likely that it isn’t the code. The first place I would check is in your scene file. Make sure that there is no Saving Wrapper, Saving System, or Fader in the scene (when the game is not running). We only want these objects to be in the PersistentObjectsPrefab. If one happens to be in the scene, when we do a FindObjectOfType<SavingWrapper>(), it will always find the one in the scene file, not the one in the PersistentObjectsPrefab that is created under DontDestroyOnLoad at runtime.

1 Like

When I check in-game when transferring between scenes, the old portal that was in the old level is still in the new level. It had not been destroyed like it was being destroyed before. Now I will have three different portals in the scene. The two that are supposed to be there and another one that spawns somewhere else in the scene. No matter which of the two scenes I start in when I transfer it brings another portal with it. Not sure how this error started to be honest. It wasn’t like that before I started adding the saving system. And if I walk through either of the two that are supposed to be there, the portal disappears, and am not sure where it went. And the persistent objects will show that there is one portal that is supposed to be there and one portal that came when I changed the scene.

I actually meant Fader, not Portal.
There should be an extra portal briefly when switching scenes, as we hold on to the old Portal just long enough to locate the corresponding portal and finish the transitions.
In this case, the Portal is not disappearing because the script encountered an error while running, the SavingWrapper has been destroyed.
That’s what we’re looking for in the scene file, when the game is not running. See if you can find a SavingWrapper in the hierarchy when the game is not being played.

1 Like

Ok, thank you Brian I will check it when I’m done at work. And I will let you know.