Download

Saving multiple actors and their associated structs to savegame?

I am making a jigsaw puzzle game. So far it works pretty well but trying to implement a save game system is proving tricky.

I spawn each puzzle piece into the world along with associated data like piece location, orientation, which 3D model, UV coordinates, which texture file, and probably a couple things I’m forgetting and I put all those variables into a “pieceStruct”. So each piece has it’s own struct with unique data and that data gets updated when the piece moves or changes orientation etc.

What I can’t figure out is how to save that data to a savegame file and make sure each piece comes along with it’s unique struct data.

Make an array of structs? Make an array of each piece of data and toss out the structs and just use array indexes? What’s the best practice for saving a bunch of actors and relevant unique data for each actos?

Array of structs definitely. What’s wrong with that?

Wrong with it? I don’t know. I am not sure how to make one. I was under the impression that doesn’t work without C++ trickery?

I have been studying the subject for years since before migrating to Unreal:

https://forums.unrealengine.com/unreal-engine/marketplace/1467088-plugin-savior-2

Big thing you have to keep in mind out of the box is that the save system in Unreal doesn’t play well with object references (textures, meshes, actors, etc);
Second thing is you will probably need C++, and asynchronous tasks (threading), but I think Epic recently did one step forward towards that.

Btw, there are several many many ways to achieve the same goal, so because of that your question becomes very vague.

An array of structs is just that. It can live in the save game as a variable just like any other variable. All you have to do is update the array in the save game.

I understand that putting actor refs in there would not be good ( [USER=“434”]BrUnO XaVIeR[/USER] ), but I don’t think you want to do that, right?

Ohhhhh I just realized how to do it by looking at your posted images! Thanks for that. What I had forgotten is that you can make a struct variable in the save game and then just click the icon to change from a single variable to an array of that variable. Stupid simple workflow mistake.