Bug in ItemDropper

Hi team,

There’s a bug in the ItemDropper script - when loading the game, it Instantiates prefabs for items which have not yet been picked up. But it doesn’t check if that pickup exists in the scene.

This means that if you reload the game several times, it creates several instances of every dropped pickup, rather than just one.

To reproduce - drop an item, save the game, then reload 5 times. You should see 5 instances of the dropped picked, allowing for item duplication.

Take a look at this thread Another bug? Item duplication when changing scenes and see if it fixes the issue.

Hi Brian,

No this one doesn’t require any scene changing. It just seems to be the way that ItemDropper implements the ISaveable interface: when reloading we check if the item has been picked up then make sure not the spawn it - but if it hasn’t been picked up we also don’t want to spawn it if it’s currently lying around. I don’t see a way to fix this with the current architecture since the pickup itself is the object in the scene.

I think it would require rethinking the architecture so that pickups are the things that save their own state, rather than the entity who dropped them.

The reproduction steps are to drop an item, save, then reload. A new item will be created by the ItemDropper instantiating it - but the old one was never destroyed or picked up.

Are you experiencing this if you drop the item, save, quit the game and return?

This may be one of the many side effects of not truly reloading the scene to a default state when we L)oad with the L key…

To fix this, try going into SavingWrapper and in Update where you check to see if the Load (KeyCode.L) key is pressed, replace Load() with

StartCoroutine(LoadLastScene());

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

Privacy & Terms