If I start the game, the "PersistentObjects(Clone) is added

I downloaded and imported the “SavingSystem” and started to write the Wrapper in parallel to the video. And I had the same issue, that I got the saving message twice. Then I found out, that every time I start the game it adds automatically a clone of “PersistentObjects”:

Even if I stop the game, it stays. If I delete it, on the next start it is added again. Why?

So, I deleted my “PersistentObjects”, but that is not the final solution for me.

You’re not supposed to have a PersistentObjects in the scene at all. In the Core prefab is a PersistentObjectSpawner that creates an instance of it for you. There should be none of them in the scene when you are not running the game

1 Like

You might want to review the lesson Better Than A Singleton, where Sam explains what’s going on with the PersistentObjects prefab.

The idea is that the PersistentObjectSpawner in each scenes loads a PersistentObjects into the DontDestroyOnLoad scene ONLY if one does not exist already.

The PersistentObjects in your existing Scene will dissappear when we move from scene to scene, which will cause a problem as the contents in that PersistentObjects will be picked up before the ones in the DontDestroyOnLoad scene. That means when the scene changes in the Portal, those references would break.

1 Like

Thanks for the explanation :v:

Yes, I did the last lesson a bit on the fly. :innocent:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms