I generated it from a widget
but how is it that I define the actor who has to save?
You have to put variables in the save game for everything you want to save. And you have to write the code to save those actor’s settings. When the game re-starts, you load what you saved again.
can you take me a screenshot of how it’s done?
Imagine I have a door that needs to remember if it’s open or not.
First, I make my save game, and I put a bool in there:
Then, when the player opens the door, we have to stash that in the save game:
The door also needs to make sure it is open when the save game says it is. So it also has the code:
Do you get it?
so write u so right or wrong?
this photo would be the portal that leads to the level where there is the actor to be saved
Yes, that looks good. Remember you also have to make the save game if it’s not there. This is the 101:
the photo you put must be written in my save game
That picture shows the 3 ways you can use it
You have the right code for 2 and 3, but you also need 1, you have to make it once…
but must it be written in the blueprint of the level??
Not at all. In fact, typically, using the level BP is not a great idea.
Each actor ( which is usually a blueprint ), will manage it’s own saving and loading.
If you have a lot of ‘dumb’ actors, like static meshes, you have to run a script to record their positions etc in the save game, and then load it again, next time the player uses that level.
Even in this little example, you can see it make much more sense, to have a blueprint that you drop in the level, that will save all the dumb actors, because you only need to write it once, then you can just put in all your levels.
It really depends what you want to save and load.
in my save game I put the variable
then of the actor or writing that is saved
and in the entrance door of the level I wrote the loading
the door is an actor
So you are spawning a door?
What kind of thing are you spawning?
Is it a table? The user is spawning the table using the widget, and you want the table to be there next time they play?
Here. I’ve made some general code for you.
In your save game, you need a ‘map’ of actor type and location:
The first part is of type:
In your widget, when you create something, do this:
And in your level BP, or your player, do this:
( This is for spawning blueprints. If you want to remember static meshes also, that’s similar, but slightly different ).
I don’t know if it’s normal but the game crashes, the fps fall from 2 to 10?
I tested this code, so I know it’s ok. I’m guessing it’s something else you’re doing.
At a rough guess, I’d say disconnect anything you’re doing on tick