Immediate Save nodes lock the game until the file on disk is updated.
The two videos above, Nilson Lima shows how to use the multi-threaded async system to save database on background.
The other video above, on part 2, author shows what he does to pick a database per level and another for player stats.
He just compares db name to level name, while naming level and db the same name.
Thank you for the answer! There were tons of replies here but I guess they dissappeared with the forum update. Such a shame.
Do you have any suggestion for saving spawned actors? For example, when I build a house, I want to save it’s existance. If it’s not directly covered with the plugin (which is what I expect), I can easily find workarounds.
Just curious if there is an in-plugin solution for that.
For spawned actors, you need to control IDs of instances stored in db files.
I would not let Unreal use auto generated actor names for spawned houses, I would instead create custom IDs to store them in a db row.
You can either use the “Make DB” functions to create a storage ID for a house blueprint, or directly store your own into a string property (of type Name) called "DBID ".
I prefere to use the DBID directly from Unreal Editor instead of using the “Make DBID” function:
When the blueprint is spawned, it will be registered with the ID default value:
I would convert them to structs that can be stored in Player State or Character blueprints.
Mark them with ‘Save Game’ and then add to the DB a column of same type to record them (STRUCT column type).
The struct should not contain object reference types if the parent container is a struct.
Object references I would store directly into the Character blueprint, and store as a separate OBJECT column into the DB.
Sorry, I did not understand your question.
You can record to db a component the same way you record actors.
If you don’t want to turn the component class into a blueprint, you can assign its DBID value from within the component’s parent actor construction script.
Thank you for your detailed answer! I’m going to try that and come back with the results. My target is saving different players’ inventories. I guess I know how to do that thanks to your post.
Hey Bruno, I tried your tutorial and everything works perfectly. Thank you again! I can save my inventory and load it as long as the id matches. I will use the same approach for spawned actors. DBID variable helps a lot.
I have question about save game slots.
Is it possible to have save game slots with this plugin? For example, in Minecraft when you create a world, it creates a new folder and your world data, inventory information etc. stored in that folder. Maybe something like that. I have a plan to have 3 save game slots for both multiplayer and singleplayer. I really like being able to save changes immediately with this plugin so being able to have slots would be amazing.
Also what do you think about having multiple databases? I noticed if I save different actor/component classes in the same database, I will have NULL values for missing variables as expected. For example my inventory and stats both have their own components. Would it be better to have “PlayerInventory database & PlayerStats database” or something covers both of them? I guess it’s not a big deal but I would love to hear your opinion about that.
the soft references for the classes fixed the saving for me. running into some multi server issues at the moment. currently the inv actor component is attached to the player controller, the server PC seems to get loaded, but the client one doesnt seem to load the saved inv.
@Emrehan I think multiple Dbs is good organization. The only thing I wouldn’t do is create multiple DBs for multiple systems * levels (one db for each level for each system), that would be chaotic.
It’s fine to have ‘NULL’ records around, but they could indicate better system design could be in place.
And about Slots, I think table ‘Versions’ can be used as slots, but you would have to wait for me to expose them to blueprints, so you could set active table to use at runtime as active slot. Currently you can’t set a target table at runtime from blueprint code.
When you add new table versionings and hit “DROP & REBUILD”, you can set on Db the target version to use, but in editor only. I will see how I can expose it to blueprint:
@anonymous_user_4d217542 the Db is authoritative.
This means, you have to replicate your Properties or pass them to the Client side with a RPC after values are loaded from Db by the server.
Client software cannot “see” the Db API of functions in C++ land.
Makes sense, I will keep your suggestions in mind!
Sounds great! I’m not in hurry, but hearing that there is going to be a solution for multiple slots is relieving. Then I can use this plugin as a save system for my game.
I think this is easy enough to use, after you create versioned tables like screenshots above (I am also fixing Details Panel refresh bug that happens when version list is changed).
thanks, i was able to create a test simple program and get the inv component to save/load properly (dbid def helped)
question though, when i am running one player in standalone, and i tell the game mode to save, i see it doing 3 insert/replace in the logs, is this expected?
USQLog: {USQL}:: INSERT OR REPLACE INTO DB_Inventory (ID,Inventory) VALUES ('testingdbid','UArray>>{ ...
USQLog: {USQL}:: INSERT OR REPLACE INTO DB_Inventory (ID,Inventory) VALUES ('testingdbid','UArray>>{ ...
USQLog: {USQL}:: INSERT OR REPLACE INTO DB_Inventory (ID,Inventory) VALUES ('testingdbid','UArray>>{ ...