So my game allows players to choose equipment before entering the main game, so I have a level that fires that equipment GUI and lets the players choose their stuff… they click play and they no-longer have their stuff…
How can I transfer the inventory from the equip screen / level to the game level ???
So I have a save game object and I have added my inventory component to it.
I create a new save_game object “My_Save” and “set” its inventory component to be equal to the inventory chosen and set a test variable from “My_Save” to a “A test” and I “save slot”
When I load that save, and cast the returned object to My_Save the test variable is set, but the inventory component is empty.
Like @Rev0verDrive says, it’s not good to store object references.
It’s a little hard to explain clearly, but it will trip you up in the end.
It’s better to store generic types if you can. For instance, if it’s an array of ‘things’, you can use integers ( or strings ) to represent the things.
Not sure I understand - Item Object is an Object, container is a struct that contains an array of Item’s (plus thing like the containers name, No. slots etc).
An object reference is a pointer to an object - correct ?
I am not storing pointers to my objects, I am storing the objects themselves (or at least I think I am), do I still need to convert everything to a string ???
You can’t store the objects themselves. That’s why you need to store an int or string.
When you read it back out of the save game, then you can spawn the correct items, depending on what’s in the slots. It looks to the player like they stored objects, but you only ever stored an ID of the type of object.
When you load the new level the object references are no longer valid. Said actors no longer exist. Thus you need to store an int/string reference for them. Then spawn them in the new level -> valid object reference.