I've had some difficulties with loading a saved game, mostly involving inconsistencies in data preserved after load:
- Player Stats not preserved
- Player Transform not preserved
- Player Inventory not preserved
- Player not equipping items
- Player equipping incorrect items
Some of this I've been able to resolve, though in any case I'm not firmly convinced that my solution will be viable as the game scales. Largely, this has been done by ordination and delaying of the On Load actions needed to set the UI, active/inactive/destroyed objects, and otherwise preserve the world/play state. I now have a wait at the beginning of the On Load actions that has to be 3-5 seconds for any success.
It would appear that the On Load Trigger does not wait for the equipment of Inventory, UI display of stats, and other elements to complete. If I do not put the time delay at the start of a set of actions from an On Load Trigger, these begin to fire, and seem to interrupt or contradict the automated Load functions for the above.
For instance, I can effectively watch while the player dresses (equips meshes) after the scene loads.
Interestingly, Global Variables seem to be always preserved, but I imagine these are among the first elements to be loaded.
And one aspect that I have been completely unable to resolve is the Inventory/Equipment issue. As noted above, the instantiation of equipment takes time, and even then, the Player for some reason ends up wearing the equipment that was initially placed in an equipment slot, rather than the equipment that replaced it and was worn at the time of saving.
In fact, if I remove that item from the player's inventory before saving, the game freezes completely on loading.
Does or should the On Load trigger occur after all reliant modules have completed their functions or co-routines?
Is there any way to determine what length of delay is needed for the automated load to finish, particularly as the game scales?
Is there an issue with subsequent equipment in the same Inventory slot not being preserved?
I haven't replicated in a clean project at this point, as it's obviously a complicated scenario.
Here is my console after saving once and then loading. Curiously, there are two save comments but no load comment.
I need to track down the missing reference exception as well. I was using your script on scene objects, but decided to go another way with that and probably haven't deleted all instances.
I have the save buttons checked where applicable (variables, player, inventory, etc. I'm loading from a separate main menu scene.
Customer support service by UserEcho