IEnumerator Start() routine bug

My start routine keeps reloading the saved scene like as if it was in an update function. I notice it keep deleting and reloading the scene in the Hierarchy and the persistence objects keep getting instantiated into the scene. This issue goes away if I comment out the yeild return LoadLastScene. Anyone have this issue?

1 Like

Have you left a persistent object in the scene as they should be removed once we prefabbed them.
I would compare to the resources github link and let me know on this as its similar to an issue posted in the Q&A on udemy so it may be the same issue.

3 Likes

Hey irresistiblejelly,

I don’t have any persistent objects in the scene. My persistent object spawn script is attached to my ‘Core’ game object. I’ve read up on the Q&A comments with leonardo, it seems he had the same issue. Below is a screen shot of my scene before running the game.

The next image is my scene while the game is running. You can see that persistent objects keep getting created. Also note, the canvas in the back can’t fade in because it keeps saving.

I’ve looked through and compared the code on git and everything matches. Is there anywhere else you can think of that I may check? Thanks again for the help

I figured it out. I didn’t think to check the Saving scripts from the resource file as I assumed that wasn’t where the problem was. After comparing the scripts to git I found that the SavingSystem.cs script in the resources download differs from the scripts uploaded to git. Particularly in the LoadLastScene function. After replacing the code, it works correctly now. Thank you.

@sampattuzzi Can we check on the github package please

It doesn’t sound like we got to the root cause. Why is your PersistentObject prefab getting created multiple times? No matter how many times we reload the scene it should only get spawned once, that’s the point of the PersistentObject spawner.

In my persistent object spawner script, in the Awake() function, I didn’t have the ‘if’ condition to check if there was already a persistent object instantiated. I’m not sure why the Awake() function kept getting called to keep instantiating the persistent objects. The game is working as intended now, so I’m going to press on and not bog myself down to much to figure out how I messed that up lol.

On a side note, you guys are awesome!! I’m having a great time learning and improving my game design and programming skills. This course is a great value and I’m very happy with what you guys are doing. I can’t wait for part 2. Thank you again for all the help!

4 Likes

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

Privacy & Terms