I FINALLY did it!
I’ve been trying for awhile to figure out enemy/object persistence. I’m pretty new to C# still so this was a huge hurdle for me.
To get it working, I basically had to have an empty GameObject in each scene that contains a list of a custom class called “ManifestEntry”, that stores a gameObject, position, rotation, state (an int, but it represents states such as alive/dead/open/locked/etc.) , and then an enum for entry type (enemy, item, door, lockedObject). This way I can manually input where enemies/items should spawn.
There’s a persistent GameControl object that previously only handled carrying over the player’s inventory and health and such, but I added a function to it that, every time a new scene is loaded, it first checks if it has a manifest stored for the new room. If it does NOT, it goes looking for that empty GameObject and copies it’s “manifest”, and assigns it an ID, so it knows the next time it enters this scene, it should load that manifest.
Whether it already has the manifest or has to find it, it then iterates through the manifest, checking for objects to spawn. For example, if it returns that there is an enemy in the manifest, it checks if the state is “0” (alive), and if so, it spawns it at the specified location and rotation, assigning it a “callback ID”. The enemy, upon death, sends a message back to the GameControl object, with its ID, saying “hey I’m dead” and the GameControl object updates the manifest, so next time it loads the manifest, it sees the state of that object is “1” (Dead) and it doesn’t spawn it next time.