Respawning Added Objects on Load

I’m wondering if it is possible to save and load objects added during runtime in UPBGE 3.0. Using the “Save Game” node saves the positions and names of all objects in the scene, including ones added during runtime. However, using the “Load Game” node only sets the positions of objects already in the scene- it does not respawn objects added at runtime. What’s the best way to go about doing this? I’m interested in creating a level editor but currently have no way of loading created levels since it uses objects added at runtime. Any help is much appreciated!

Here is an example scene if you’d like to see what I’m talking about. WASD moves the cube, Spacebar adds an object, Left Bracket saves, and Right Bracket loads, but you’ll see loading the game does not respawn added objects after restarting it. (Uses UPBGE 3.0, the Save/Load function does not appear to be working in the latest release)
saveloadtest.blend (947.0 KB)

ofcourse it’s possible.

Write your own save/load script or look at mine and see hoe i’ve done it, for upbge higher then 2.5 you need to alter stuff, and better use bpy code to make it even faster.

2 Likes

Very cool.
Cotaks Script works fine.
Here’s the example scene with the Logic-Node system replaced with Cotak’s script.

adaption:
    
hit 1 to save
hit 2 to load

save file be be saved to folder "Saves"

03_saveloadtest_Cotak_Script.blend (986.1 KB)

In UPBGE 0.3 and higher it will only save the current Scene. To make it work to save all scenes you would have to modify the script to use some bpy code as Cotak mentioned.

1 Like

Your script works flawlessly, thank you! And thank you for the additional info, I only need to save the current scene so this works great.