I want items dropped in a level to remain even after moving to a different level and returning.
I also want to save the status of items placed in the previous level (e.g., gatherable herbs, destructible ores), as well as save respawn waiting information.
Hey there @Baetong20! Welcome back to the community! So generally from a high level, you need to create a manager that stores the data for relevant items either for just the session (recommended for shorter form games) or saving the data persistently in your SaveGame logic, then spawning on load + setting correct data (for longer form games that require persistence across saves). These are essentially the same system, the primary difference is saving the data or not.
Here are some resources:
This goes over data persistence for the session, in this case in the game instance:
This course goes over longer form data persistence, like saving objects in levels:
Depending on your game’s scope, the saving and loading method can be quite cumbersome. It’s best to shed as much data that is irrelevant to the save process as possible, and only save items that must be saved. Most games, even large scale persistent games don’t keep too many items saved and loaded in, and generally only allow them to be semi-permanent in very specific locations, like player homes.
Asynchronously loading the relevant items first is also another widely used trick, where you only load the immediate area first, then only load the others right before they become relevant.
As for the data that you’d need to store, it’s extremely dependent on your game. You will generally need the actor class unless it’s just a mesh, then you can get away with just location and mesh data for example. The best way to think about it is “What does this need to be the same item without the need to save every single variable on it?”.
If your item doesn’t already exist at runtime when the level starts, yes you will have to spawn and assign the variables that were saved to it.
However, since you mention it’s just one object, all you would have to do is save the position and scale, and a way to identify the object in the scene if it exists at level start. If you have to spawn it when the level starts and it’s not just a simple mesh, you would want the class saved too so you can create it when needed.