Can you store actors in the game instance?

I have a party based game. I need to save around 40 actors in total for quick access. I thought a good way to store them would be in the game instance as an array so I could access my party between levels, but whenever I reload the map, the actors are still in the array, but they have all reset to their default (null) values. All my other variables save fine except the actors which reset.

Is this not possible or is something else going wrong in my code?

Thanks for any help! I’ve hit a wall on this one

That’s how it is supposed to work. All actors are destroyed when you leave a level, and the values of all of the actor’s variables disappear when the actor is destroyed. When you move into the new level, your game instance is referencing an actor of the same class, when means a new actor is getting spawned, but your existing code does not have any way to load the old actor’s variable values into the new actor. To make that happen, you need to store each actor’s variables (either in the game instance or in a save game) before you leave the old level, then load them into the corresponding new actors when you start the new level.

There are many good tutorials on save game systems. For what you are describing, you don’t need to actually save to disk; you can just create save game as a variable in your game instance and use that.

Thanks for clearing that up. I’ll do just that!