I have asked this question before and while the video on persistence and save/loading using serialization helps with some of the other stuff I had to do, this really doesn’t apply to what I need to do.
I have an object that once its health gets down to 0 that it should be destroyed and stay destroyed. The problem I’m having is that once I do anything with loading a new level, whether it be the character information screen, the menu screen etc, the object that gets destroyed will reappear so if anyone can point me in the right direction on how to save the state of a level or game object (I’m thinking level because the game object should be destroyed and therefore as far as I know can’t really save the state of something that’s destroyed) that would help.
As I stated in the past, I really hate to ask for code like this and in no way do I expect people to write my game but it is hard to type in code then test it when I don’t even know the code and just like that video, although it will help in my save/load functions it doesn’t apply here so again I’m at the point of trying to figure out what documentation to go to that really applies too, and that’s why I keep asking people who has experience in this.
So you have an object that died, and you are loading a new scene that is not the same scene the object has died in, but the object could exist in this new scene and you want it to be dead?
Example…
You set things up in a way so that in every scene there is a special item, however, the player can only take that item once. If he took that item in any scene, all the other scenes must remove the item so the player cannot get it again.
I have not really touched anything that has to do with saving/loading, so ill just spit some ideas.
You can have a “public static Dictionary<int, bool> objectsLife” and at Awake, assign all that can die to that dictionary like “…objectsLife.Add(int, true)”.
Each object will need a script component that stores its id.
If you need to save this information for even after the player closes your game and rejoins, than you will need to save it somehow possibly with playerprefs and what not.