How to save a pointer to file


I’m working on a save system in my game and I need to save a pointer to file that after being loaded will point to the right object. (The pointers I’m saving only point to objects that are created in the editor - not the ones that are spawned at runtime.)

How can I do that? Maybe there is another way to reference the object after restarting the game and loading the save, something like unique ID?

Hello Ogniok,
Why you do not want to use a file and load it at start up?

I want you use a file. I have a pointer to an object. I want to save it to file. And then, after I restart the game I want to load it. But as far as I know normal pointer won’t be pointing to the proper location in memory after restarting the game and being loaded.

Looks like I not understood your question at the first time. You can not save pointer to the object, but you can save data from object and then create a new one at start up. I’m not very familiar with the UE4, but suppose that there should be something for the object serialization.

I know about object serialization - but I don’t want to save the object but the pointer to it. Lets say the player selects one of the objects on the map. Then he saves the game, restarts it and loads a save. How can I know which object he selected while saving? I need to include the pointer in the save.

When you load your map all your actors are present.
But they are all recreated, so they are other objects then before.
You can give the objects unique names and then save the name.

I know I can give unique IDs(in example names) to actors, but what I’m asking is do they have something like that already? In the engine I worked before UE4 every object had unique ID that was always the same even if I restart the game and load the map again.