Another stupid question: what’s the proper way to get all instances of the blueprint in level, save only ones with boolean on and then load its state based on this boolean after loading game save?
I have a light switches and would like it to be saved. Can’t get a proper way to do it using array and loop…
It’s just a bool array. Each light switch has an integer ID, which is it’s index in the array.
Whenever they’re used, they save their status in the save game, you don’t need to do it all in one go. You only need to code it in the light switch blueprint once, the rest happens automatically.
When the game starts again, each light switch knows to read it’s own status from the save game and set itself accordingly.
Trying to do it all at once is a bit of a mare, and combine that with structures, it’s no wonder you have a problem… ( they’re not easy to work with ).
This solution is great, but I can’t find a way to adapt it to the save/load system I already have. Could you give me a hint how could I fix it to properly save/load from slot to save lights on and off?
Your light BP seems good. Sorry, can’t debug your save/load BP, it’s a total nightmare
You don’t need anything to do with the lights in the save load BP, because the lights are already managing themselves. It’s a much easier way to do it.
Basically all of that stuff in the save/load BP needs to go in the individual BPs, then you might be able to see what’s going on.
Hey, I’ve finally managed it to work - at least, partly.
Thank you!
Something weird is going on, though: it works perfectly when I enable/disable lights and then load the game. When I enable/disable lights, click “Save game” and then “Load game” - light status won’t load. That’s strange…
When the lights change status, it IS already saved. Try changing a few and then restarting.
So I’m deducing, there’s something shifty going on behind that save button, which no doubt involves saving an out of date version of the save game ( on top of the good one ), which is why it’s not working
If you want the game to only save when you say so, the whole structure is somewhat different.
Hm… yeah, the whole point of a question was to save states of some objects (I wanted to learn it with toggle-able lights) via manual saving/loading (old school thing). How could I adapt this blueprint?
Now we need to code something in save game actor, right?
Change that begin player to a custom event ‘load status’ ( or something ) and do the same thing with a foreach loop from your widget to load the lights.