SaveGame: How to save objects attached to sockets

So I’ve created a whole inventory/equipment system and It’s working beautifully. I can pickup, and equip items and they attach to sockets on the player. I’ve begun the process of creating a save game function, but I’ve run into a major problem. If I go through the game, pick up a weapon, attach it to a socket, and then save the game - upon loading the game All the necessary information is in place, but the weapon is not attached to the socket. If I open the inventory the weapon is [technically] there. Or, at least its information is stored in the proper array, and the UI widget is updated.

My Question: Is there a way to save what objects are attached to sockets on the player character?

You cannot save object pointers to a savegame file (unless you do it manually through custom code, if done in Blueprints it becomes too slow then C++ is needed).
Everybody comes across this kind of problem because at first they don’t know this problem with save game system… They build game system everywhere based on object references then wonder why stuff can’t be saved.

The problem is internally the save game system can only “see” basic properties like Names, String, Float, Int, etc.
When you have a “Object” property, it will not save a pointer to that object into the .sav file, it will just skip that type of property entirely.

People do a lot of different hacky things to solve this issue; what I did was stop using the “FArchive” stuff that the engine uses internally when you write to a .sav file.
But for Blueprint only, if you want to do this for just a small bunch of actors, you can save a “path” to the object in your object property then try to restore that object reference property whn game loads; if you do that for many actors tho then your load times will increase too much.

1 Like

I was thinking this morning… I could Create a variable that stores information about the “weapon” that’s been attached. I populate this variable when the player actually attaches the weapon themselves. Then I pass that variable into the save game data. When I load the game I do a check for the variable and have it run the attach function. Basically it would just be If var is not null? or something like that. Or perhaps easier to create a bool that sets to true when that other variable is populated.

So something like:
Var weaponitem = “itemname”
Var weaponEquipped = true

do a check for WeaponEquipped = true if so then pass WeaponItem into the attach item function and run it again. So the item attaches. I’ll have to figure this out, but I think I’m on the right track. Thanks for the info. I can at least stop hunting for a way to save the object pointer/reference.