Pickup Spawner bug

I found this bug by picking up items on the ground, go to another scene and go back. Then i press L to load the save file, all the pickup items appear once again. Apparently, when I try printing out like the image below:


The result is:image
The load file works fine but after loading the scene, isCollected() return false even though there’s nothing inside all the pickup spawners:image
I thought i made mistakes somewhere so i tried download the course github code but this problem also occurs.
How can i solve this?

i randomly found the answer for this bug. By changing the order of saving in portal script below:

to
GetComponentInChildren() doesn’t return a clone pickup anymore (even though there’s no child object in unity editor in the first place). The problem solved but I don’t really understand what happened, hope someone can explain to me.

Interestingly enough, I was unable to duplicate this bug in any of my forks of the current Repo I’m working on. I wasn’t able to figure out a cause for what was happening on your end, or how the switch to moving Save until after the Fadein would prevent this.
That being said, delaying the Save is a quick fix for some other bugs in our code that I’ve written about from time to time related to initializing variables referenced in Save/Load in the Start() instead of Awake().

I’m glad you got it working proper.

i got the source from the last lecture of RPG Inventory Systems: Intermediate C# Game Coding - lecture 61: Fixing a saving bug. I go to the lecture’s github commit and download the code. I don’t know if this picture could help:


Step to get to the problem are:

  1. Run the Sandbox scene.
  2. Pick up the flower item between 2 guards.
  3. Go to the portal and load Sandbox 2.
  4. Go back the same portal and load Sandbox.
  5. Press L, the flower appears.

At least the bug is fixed somehow but would be nice if i understand the reason behind it.

I’ve tagged Sam in on this to take a look, as I still can’t replicate it.

This topic was automatically closed after 26 hours. New replies are no longer allowed.

Privacy & Terms