Saving System for Dropped Items

Hi,

I had a question about the method for saving the item pickups. The player is saving a record of items and locations that have been dropped so they can be serialized and reloaded when the game is reloaded.

This leaves two categories of pickups, original pickups with pickup spawners and dropped pickups recorded in the list.

Why not just make the pickups themselves savable objects? This would mean all pickups are treated the same and re-spawned when the game is reloaded.

Is there a reason it was done this specific way?

Thanks.

Once you’ve picked up the pickup, it won’t be seen by the saving system.
The PickupSpawner maintains a list of pickup’s it’s responsible for, and remains in the game even after the pickups themselves have been picked up.

Once you have picked up the pickup, isn’t saving it handled by the inventory system? Then if you drop it again it can be handle by the pickup saving system. So there is no need to have a third category of items that have been dropped. They can just be any normal pickup at that point.

No, because that normal pickup may or may not exist in the saved scene…

There are two factors at play in saving and restoring a scene:

  1. The SceneManager loads the elements of a scene
  2. The SavingSystem restores the attributes of those elements in the scene.
    If it isn’t in the scene file, then the SavingSystem has no link to restore the item.
    The ItemDropper and DroppedItem game objects act as that link.

Imagine I pick up a sword in scene 1. I now move to scene 2 and drop it, then return to scene 1… When I go back to scene 2, the sword isn’t in the Scene file, so no matter whether I saved it or not, it won’t be restored because as far as the game is concerned it does not exist.

So then is saving them in the scene file an option? Aren’t other pickups saved in the scene file in order to know if they have been picked up or not?

The scene file never changes. It is the Heirarchy structure when you press play. You cannot change the scene file at runtime, nor would it be a good idea to do so if you could.
That’s why we have the Save file, to manage the state of the objects in the scene file.
The pickups aren’t saved in the save file directly, the PickupSpawner saves whether or not the pickup that it is responsible for spawning has been picked up. The ItemDropper maintains a list of pickups and their positions.

2 Likes

The saving system in the RPG game also saves whether or not the pickups have been picked up in each scene. This is what I meant by the scene save file. We are saving information specific to each scene already. Just discussing this though has made me see how trying to generalize might be more complicated, since those pickups in the scene when it is loaded are attached to pickup spawners.

Right, when I speak of the scene file, I’m referring to the .Scene file in Unity, the heirarchy. Generally, all of the SaveableEntities in a Save file should have a corresponding element in the .Scene file. While the SaveableEntities may be able to create objects based on information from the Save file, the inverse is not true, without a SaveableEntity to latch onto, it’s just extra space in the save file.

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

Privacy & Terms