Save actor array and load

hello, I’m trying to make a system to save my game, I have a chest with an array type variable inside it that is used for the chest’s inventory, I want to save this variable and load it when the game starts, plus all that I try wrong. help


Assuming the load/save to the CurrentSaveData is working.

CurrentSaveData → Chest will be over-written for each of the chest actors.

You’ll need to make a system that stores each of them.

something like that?


The default Unreal’s save game system cannot save array of actors.

It can’t save any references to instanced objects.

You need to do a workaround for such stuff.

An approach i’m on is:
Give each chest a unique name.
Give each Chest the Tag “Chest”
In your gameinstance, add a variable of type map, which used name as key and as value the inventor Struct.

On Chest spawn, add the chest name and Struct to this variable in the instance.

Since a map holds each key unique, your chest can use their own name to get and set values there.

When saving take the map, foreach every key and store the Inventory Struct.
As same as an array containing each name/key

On Loafing, get the Name/Key array first and fill the map with each, missing and filling the inventor according to it.

After loading, GetAllActorsWithTag “Chest”.
Foreach the resulting array and try to find the actors names as key of the map.
If it found one, write the inventory to that chest actor.

I’m not on my PC right now. but that is the method i try to store my own Inventory with.

1 Like