Maybe question is too general, but I am asking if such mechanism exists in Babylon or someone is ready to share some approaches.
And before trying any obvious suggestions I would like to share what I am looking for.
What to save?
Static objects (objects that will not change during all level life time: building meshes, landscape, some lights).
Dynamic objects (objects that might be moved, resized, altered, created or destroyed).
Physics state (if some box was thrown, it should keep it impulse after saving and loading).
Timings (grenade delays, timer before door will start to close. Notice: I never use setTimeout for such purposes I always attach callbacks to main loop via OnBeforeRenderObservable and put frame counters there, then remove callbacks if it’s not needed anymore. I think that this approach is more safe and helps to keep code execution more predictable).
Actors stats (positions, health, weapons, ammo for player, NPCs and monsters).
AI cycles (if NPCs or monsters logic has some steps, it should be saved also. For now it might be skipped, I didn’t implement any AI for now).
When to save?
- Checkpoints (much easier, we can put them only when nothing is happening. So we’ll need only to save static objects and some player’s stats. Other things from the list above might be evilly truncated. )
- Anytime (like the Doom did. We’ll need to save everything. Actually I am looking for such ‘anytime’ approach).
How to save (what to put into file)?
- Full dump (the entire level will be loaded from the file. Usually it creates bigger save-files).
- Everything excluding static objects (for each Level-data file we can assume two sections
loadDynamicPart. First part will always be loaded from Level-data file, the second part might be loaded from save-file if provided or from Level-data file instead. It should create smaller save-files. To be honest I am not 100% sure which approach is better.)
I am not sure what BABYLON.SceneSerializer may do for me from the lists above. I am pretty sure that I will need something more and beyond of it. That’s why I am asking how to start this incredible adventure.