My current plan is pretty much everything that needs to be saved inherits from a DynamicActor class.
On save, all objects of this class call their own SaveInfo method that can be overridden by children to add more info that not all objects need (like info about what plant is being grown in objects that can grow plants).
On load a boolean LoadingGame is set, all objects in the save that belong in the current level but aren’t there already are spawned in the Level’s BeginPlay event, and DynamicActors on BeginPlay will change their state if LoadingGame is true (including destroying themselves if they aren’t in the save).
So far it seems to be working but can you see anything wrong with this plan that can’t be fixed?
- How do I know when it’s finished loading so I can set LoadingGame to false? If I don’t do this anything that spawns in the world will be immediately destroyed. What’s the last thing that happens when a level is opened?
- Is there a way to reparent built-in classes (I guess the right one would be Pawn) to DynamicActor so they can be saved without repeating myself? It’s not too much trouble for the player but for enemies I would need an array similar to the other DynamicActors.
- I am saving/loading the FirstPersonCharacter without doing the above, and it works fine on a basic testing level but on my PersistentLevel when I load, I get an extra pawn that spawns where I saved and the one I’m controlling just spawns in the default state. Why?