String Array in save class wont add items to it...[help]

Not sure if burnt out or missing something obvious. I was getting my savegame in the parent pickup and then making a save function which called a function in the save game class that took in a string and adds it to its array then saves the game. The issue, it doesnt work. Nor does it save the content and nor does it add to the array. It always prints length 1! :confused:


EDIT: in the screenshots I got a reference to save (and removed the get fromt he parent) in an attempt to debug it.

This is really stupidly weird. So in my Game Mode I do have a reference and calling it from there works as intended. Getting a ref in the class itself does not work. It just saves 1 entry and doesnt even permanently saves it…

completely weirded out now.


this returns NULL?

however getting it from the game mode directly and then calling a function works no problems. What the hell is going on?


this also return null references despite the array having it saved.

This

image

should be ‘As BP Save’.

Also, don’t cross wires like this ( share a variable between code tracks ). There’s no guarentee the variable will be valid in both lines of code.

this is in the BP_Save Class however. I am using switches that are toggled the same and it does work. However I am calling that save from the BP_switch via the game mode which then uses its save variable to call “save switch” function.
Again the self is within the SaveGame Class…

It’s never going to be Self :slight_smile: It will be a save game variable reference.

Do not save the game inside the save game object.
You should be more careful in organizing the call and save of the save game object:

Game Mode:

Another Blueprint:

BP_Save:
image

I hope it’ll be helpful.

My Products

1 Like

okay hold on, so it seems I am a bit confused. I shouldnt save the game within the BP class of save game? Just use it to store values but the actual saving should be within the class I am trying to save from?
Second, every class that needs something saved should have a seperate BP save actor? So getting the save from the game mode is not ‘correct’? I thought it references one and the same thing.

weird thing is im storing 2 class data within the save game and those work fine. However specifying a save game reference with an input now seems to work. I built the system so it saves within the save game. I have added a reference to the Save Game function which takes a safe game bp now

You can save from the inside, but be careful. Don’t use self, and make sure you save the actual instance, so you don’t overwrite the previously saved data.

1 Like