Mass Saving Of World objects.

Hello!,

So i am thinking of having respawnable ores and stuff that can be mined/harvested. but i dont want to save each and every item to check whether it has been spawned/how many items remain in that ore etc etc. so how can i easily save all these. (i do know about savegame stuff, i wanna mass save these somehow so that i dont have to save all of those one by one.)

Does saving the actors of class also save their location / variables in them? because this is important

Hi, you could use “get all actors of class” and save the whole array. And when loading the level you can spawn all actors again with a for each loop.

Does this answer your question? I’m not sure if this is what you asked for.

No it won’t.

To do what you want I suggest writing a function within each base class of actor you want to save. This function when called will copy all necessary variables (actor class, transform, lifespan, resource type, resource level/amount etc) into a struct and it will pass this info to a global blueprint like the game instance. Then allow your game instance to take all structs from all the actor types you wished to save, put it into a giant array and save that array out. When you load up your game, call a function that takes the saved array of all this data, opens each struct up, spawns in the actor class and then sets its member variables. I would make all your structs the same type and when you spawn each base class in, expose the struct variable on spawn so you can pass all the data through to the spawned actor. Then have the spawned actor set its individual variables from the given struct on begin play.

you could create a structure variable and save the transform and all the necessary information in there

Yea. That’s what I was saying haha a function to do this would help make it more efficient to if there will be multiple class types being saved.

hmm alright ty :P.

If you need an idea of how to go about this, here is a simple version. You would just need to add the other information you want saved into a struct like I mentioned above and pass it through when respawning the actors you want.