In my Game Instance, I have two variables, which are arrays.
I made a Save Game. It has two variables, which are arrays.
When I write to the Save Game, I set the Save Game’s arrays to my Game Instance’s arrays.
I begin my game, store some data in the Game Instance’s arrays, and save that data to the arrays in my Save Game. Whenever I print the data in the Save Game arrays, it is identical to the arrays in the Game Instance, thus this part of the process works as intended.
I then close my game and reopen it.
I load the data from the Save Game arrays into the Game Instance arrays. When I print the contents of my Save Game arrays, they are empty. There is no data… This is the problem. The data did not in fact save, for whatever reason.
Do you know why my data is not saving?
I was thinking maybe it was because I was setting the Arrays, maybe you have to manually add each element to them. I tried this however, and had the same problem where it was not saving.
You didn’t make the connection between the Return Value of Does Save Game Exists and the next Branch statement… so under no condition is the Save Game actually being created- so all of the casts will fail if the save game doesn’t exist. I’m not sure that will solve your problem but you should definitely fix that.
I am assuming that you do see the “saved” message being printed on the screen. Does it get printed?
Also, I recommend that you put your save game Slot Name into a variable somewhere, just as a constant, and use that instead of retyping it over and over. It’ll save you trouble if you want to rename it and protect you from typo-induced errors. : )
aaaaaaaahhhhhh its always something like that, thanks for pointing that out for me. I fixed the return value into the branch.
I do see the “saved” message being printed, and have somewhat promising(?) news?
Now, when I save the game, close it, reopen it, load it again, and print out the values to see if it saved, ONE of the arrays did save ! but the other one did not.
In the code I showed you, the yellow array of Vectors (occupied_tiles) did save, but the blue one, which contain actors, did not save.
Does anything look inherently wrong as to why the yellow array is saving but the blue one isnt?
Oh- I don’t think you can just save actors like that…
You’ll need to store the aspects you want to remember about the actors and then re-spawn them on loading. I recommend you create a custom Structure to store what you need. It shouldn’t be too complicated- just save the Transform and whatever custom properties you need to have saved. You could have a function take in an actor and “struct-ify” it and have another take in the struct and spawn the actor.
hmmm… I currently am able to get the array of actors to store them: like when I save the game, and print out the elements in the actors array, it prints out the name of all the actors that i have in the array. But like I said, when I close the game, reopen it, and load the saved stuff back in, the array is then empty again. Does this still agree with what you said about not being able to save actors like that?
Currently I have it so that whenever an actor is spawned, it is added to that array. Each actor has a type, stored as a variable, so perhaps instead of storing the entire actor in the array, I can just store a string with its type, or something?
Tldr: Even though it fills the array with the actors initially, it still doesn’t save, does this make sense with what you said about not being able to “just save actors like that?”
I managed to use the string method (was going to use struct method but didn’t feel like it, strings work fine, although i do have some other things to spawn that will most likely be using structs), but i managed to get everything to save and im able to respawn all the actors in the same spot correctly!
i am also able to destroy one of the actors and have it automatically save B)
thank you for your assistance my friend, although i still have a LOT to do with save game stuff, i think the majority of it is at least somewhat understood now.
thank you friend, you telling me that full on actors couldnt be stored in save games was crucial.
I think the reason one cannot save a full actor is partly because the variable referencing it is not a primitive value, but is a pointer to a memory address. That memory location will not be the same next time you load the game. So you’d just be saving the memory address and not all the data at that address. Can anyone confirm if this is correct?