Hey, im having a problem with the game im working on.
In the game, we created a custom solution for level transitions, in this custom script a transition can be set as
"Additive" (The level loads on top of the first level for a seamless transition) and
"single" (A simple level transition).
The problem we are having is that after an "Additive" transition the inventory remains with the player as it should, but after saving the game, and loading it back again the inventory gets lost, even if we print the current inventory on console with a script the inventory appears to be empty, if we get some more items and save and load again, the problem no longer occurs and the inventory remains, so this is only happening after an "Additive" transition and on the first cycle of saving and loading, also the save file is not getting corrupted or has missing the inventory data, because if we check it from the save game manager the data is there correctly as it should, and there is nothing clearing the inventory either on the start or load action lists from the level, another thing we noticed is that if instead of loading the game with/from our main menu, we load the game from the save game manager using the load button included, the inventory appears correctly, so we are not really sure what may be the problem, help!
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
To clarify: this issue only occurs when using your custom script?
Switching levels manually is a separate operation to loading a save file. When you load an AC save file, AC will handle the scene-switch automatically based on the data within.
AC can handle additive scenes without the need for custom solutions - the Scene: Add or remove Action can be used to handle this. If you add scenes manually, you'd need to go through the SceneChanger script's AddSubScene function so that AC is able to register it correctly and include information about it within save-game data.
What's the intent behind using a custom scene transition? Generally it's best to rely on AC's provided functions/Actions, and use event hooks to run additional code if necessary.
yes, our current version of AC is not up to date, that is the reason we dont use the AC provided functions, yes switching the level is not doing anything that relates to saving the game, that is the weird part, only after we use our custom switch, in an "Additive" load mode, and after the switch, when the game is in a state where is safe to do a save and load, we do it and the inventory breaks, but only in the first save/load cycle, and about "AddSubSecene" our problem with that function is that in our version of AC we cant use it because we can only use it in "async" mode in "single" load mode and not in "Additive" load mode.
One way we found to circumvent this problem, is after loading completely the game we load once again using the selective load node, and only load the inventory and that solves the problem, but it affects performance for a couple of seconds at the start of the game after load.
What is the specific AC version you're using? If updating completely isn't an option, you could try importing just the latest versions of the files that deal with scene-switching (SceneChanger / SubScene / SceneInfo / ActionScene / ActionSceneAdd).
This issue will be down to the specifics, and I only have general details. If you're using AC's API to load a save-file, and Inventory isn't loading, then it's either a case of the Inventory never being loaded, or being loaded and then cleared.
What exactly is in the Inventory when the issue occurs? Nothing at all, or the Items that were in the Inventory before loading? This data is loaded from the RuntimeInventory script's AssignPlayerInventory (called from SaveSystem's ReturnMainData, if your AC version doesn't have this) - try placing debug logs in there to check if it's being run.
Sorry for taking so long to answer, the current version we are using of AC is 1.74.2,
the inventory is not being loaded for some reason but the inventory data is on the save file, we checked it from the save file manager, also if we load it directly from the load button from the save file manager it loads correctly, the items are items from "scene1" we do an "additive" seamless level transition to "level2" and the inventory is still there, only after we save and load is that the inventory dissapears, and it only happens once, if we save and load again on the same run, and we find more items in "level2" those get saved and loaded correctly.
Which scene an item is originally in (i.e. the Hotspot used to get the item) won't be a factor - once an item is in the Inventory, it'll be global data.
Put your custom code aside for the moment, and add the scene using the provided Scene: Add or remove Action, and save/load using AC's provided Actions / functions. Is the Inventory data then loaded?
When two scenes are open at the point of saving, any sub-scenes will be recorded in the save data - check the Save File Manager after this latter test to see this listed, and compare it to a save made when using your code. Is there a difference in the way open scene data is recorded?
Hello Chris Happy New Year! sorry for taking so long to answer, i dont think the save file has something to do that is because:
1# if we save after the transition and check the save file, the save data for the inventory is correctly saved on the file, if we load that file the inventory does not load, but the file does contain the data, if we save again the inventory data will be empty because the game detected we did not have any item in the inventory during the save.
2# We use only the AC functions to save and load.
3# If we load the game and on the loading action list of the level we selectively load only the inventory using the nodes and functions of AC, the inventory appears correctly (This lags a couple of seconds of the game after loading).
So all of the data is on the file, but for some reason it requires to load the inv selectively or save and load a second time in order for the game to continue saving and loading correctly, but this will erase the inventory data that was alredy saved correctly in the file but not loaded for some reason.
Does the custom code you're running impact/replace any of the processes involved here? It's not clear if this is down to some long-since fixed bug, a custom script involvement, or the particular technique being used.
If you can PM me your project with a set of very clear instructions to recreate, I will take a look.
The project is very large almost 70gb, but if you are open to it we can have a call, or you can connect to my PC via parsec, it would be really helpful.
Please let me know the details above re: your custom code. This is an appreciably difficult issue to convey, but I must know as much detail as you can provide.
I do not need the full project - create a paired-back copy that only has a couple of scenes, no graphic/audio assets, that is enough to demonstrate the issue.
Otherwise, create a .unitypackage file that includes the scenes, AC, your custom scripts, and import it into a fresh project to test that the issue can be recreated. If so, PM me the package with instructions and that should be enough.