Don't forget to delete the persistent prefab from all levels

Just spent hours trying to figure out why it was throwing an error, saying the persistent fader object was trying to be accessed but had been destroyed, but only on the second teleport and only if I started from one of the levels. Poured over the code, re-wrote some of it, re-watched all the lectures. Turns out I had left a copy of the prefab on the second level and it was being called by the teleporter and first and deleted. In hind sight was pretty obvious.

1 Like

Yep, this is a common occurrence. Glad you were able to get it sorted.

I had a similar error being thrown but even after I deleted the prefabs in the scene it was still being thrown. I found that the issue was the following

  private void SpawnPersistentObjects()
        {
            GameObject persistentObject = Instantiate(persistentObjectPrefab);
            DontDestroyOnLoad(persistentObject);
        }

In my version of the code I wrote DontDestroyOnLoad(persistantObjectPrefab) instead of persistentObject.

Thank you! I had this issue and also forgot to assign the PersistentObjects to one of my scenes core object. (I was iffy about prefabbing core but finally did just now)

Protip: If you’re replacing working items (ie. Core) and are worried about deleting the old assets you can hide them
image

by clicking this arrow Unity acts like they don’t exist. So you can try out the changes and if something is messed up you can easily revert =]

Privacy & Terms