I have been working on a system for saving the states of actors of various types to save game slots upon unloading a level so that they can be reloaded with those states upon loading that level again. For some reason, however, actors of the NPC type don’t seem to load again after returning to the level.
It starts out easy enough. When we click on a door to a different level, we check to see if it’s locked and trapped. If neither is true, we move on. Then we check to see if a save game slot with the name of the level we are leaving already exists.
If it does not, we create a new save game slot with the current level’s name, get all actors of the class BP_NPCBase, save their stats through a custom function, then save the slot and move on to doing this for Items.
If a save game slot exists with the source level’s name, it does basically the same thing but it loads the existing save game slot first.
after that it cycles through doing this for different classes, i.e., items, creatures, and doors.
Once it finishes all that, we start loading things in.
The first thing we do is load the destination level. Then we check to see if there is a save game slot named after the destination level. If there is, we delete all of the NPCs that exist in the level we’re loading (this way we don’t duplicate things placed in editor and spawned from the save game slot’s map).
Then we move on to spawning the NPCs
From the save game slot, we get its NPC Manager variable which stores each NPC as a four-digit name variable mapped to a struct that contains all of the stats we need to spawn them. For each key, we check to see if the npc is dead, and, if it isn’t, we spawn it.
And that’s pretty much it.
I’ve been trying to debug this for a week to figure out where it goes wrong. I have an NPC placed in the editor next to a door to different level, go through the door, come back and there’s no NPC there. It was working before, but something I did somewhere along the way broke it. I haven’t been able to figure out if it’s an issue with saving or if it’s an issue with loading.
I also cannot locate the save game files on my computer; one thing I wanted to try was deleting them and starting over to see if that resolved the issue, but I can’t seem to find any .sav files anywhere on my hard drive.
Help?