Unity 2019.4.0f1/AC v1.71.5
Hi everyone,
I have a simple OnLoad Sound: Play music Action, so that whenever the game is loaded from the Load list, the background music plays from the beginning of the track. As far as I've tested (Unity Editor and Android), it works well for any other slot than the Autosave. When loading from the Autosave slot, the music starts playing from whatever point it was at when saving, which isn't ideal. I'm using the LoadScreenshots Menu.
When looking for solutions, I found this:
https://www.adventurecreator.org/forum/discussion/8325/autosave-switched-off-in-save-menu
and this:
https://adventurecreator.org/forum/discussion/5672/running-actionlist-before-loading-a-saved-game
but I'm not really sure if either applies to my issue. Please advise.
Thank you for your time.
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Precede the Sound Play music Action with an ActionList: Comment Action, enter in some text and check Display in Console?. Does it appear in the Console window when loading the Autosave?
I'll attempt a recreation. Can you share screens of your SavesList element's properties, and the ActionList?
Can you also describe how and when your Autosaves are recorded?
Hi Chris,
Many thanks for looking into it.
The text does appear in the Console:
Here's the SavesList for Save:
and the SavesList for Load:
and the ActionList:
One additional piece of info after some more testing today. The issue seems to only surface when loading a pre-existing Autosave; i.e. in both Unity and Android I had Autosaves from yesterday. When loaded today, from within a newly started game, the issue is there, but after overwriting the Autosave slot and then loading it from that same game, the music plays from start as it should.
Not sure what you mean by "when" in your last question? I'm not deliberately using any Autosave option in the game. By Autosave I mean the first slot. As for "how", here's what's in the Console when saving to the first slot, if that's what you mean:
I hope I'm not being too confusing; still treading on uncertain ground here.
Thanks again,
Jo
So it's recorded just like any other save - by clicking in the Save menu? Doing so shouldn't produce an AutoSave if one doesn't exist already.
I can't recreate the issue, but which slot was loaded shouldn't have any bearing on the behaviour of the load process. Nor should what time it was saved. It may be more to do with the circumstances around it.
Are you saving/loading from within the same scene, or different scenes?
Let's try another Console message to be sure of the ordering. Open up Music.cs, and insert the following into its LoadMainData function:
Clear the Console just before you load the save that causes the issue to occur. Does this message display before the one coming from the above Action?
Correct.
The same scene.
Just wondering, could it be something with the saving process rather than loading then?
FWIW, I remember adding the audio file and the OnLoad Action to the game AFTER running the "Auto-add Save components to GameObjects".
If it's a bug, it's an elusive one; no issue when loading the pre-existing save from the first slot on Android today, while the issue persists in the Editor.
Elusive indeed - I can't recreate any such issue.
Though, your Console window mentions save slot 1 - the Autosave relies on save slot 0. What's making you describe it as such - is it named "Autosave" by AC in the SavesList element?
Since the data is restored before the OnLoad cutscene is triggered, it shouldn't be. But with a bug like this, we should consider the possibility.
At the top of the Settings Manager, you can click Manage save-game files to bring up the Save Game Manager. This will list all save game made when running in the Editor, and clicking on them will list its associated data (expand the "+ Data" label at the bottom).
Can you share screenshots of the "Main data" section for a save game file that has the issue vs one that doesn't?
Not in the SavesList element itself, it seems (I already posted screenshots of those above), but in the Game window - yes, the first slot for both the SaveScreenshots and the LoadScreenshots Menus shows as "Autosave". I have recently downloaded these from AC Downloads and they are the ones I'm using in the game.
On to the Save-game Manager. I have three Save files there, the first one being the notorious "Autosave", yet the "Is auto-save" says "False" and the ID is 1 rather than 0, as you pointed out - could that be the culprit?:
The "Main data" section is looong. Do you need all of it?
Sorry, I'm not clear. There are six save files showing in your in-game screenshots - 5 regular saves + the autosave. Is that from the game running in the Editor? It should match up with what's in the Save File Manager. If not, what do the menus look like in the Editor when running?
The Data section has a Main Data and Level Data sections, though Main Data shouldn't be too long. Let's just start with the "Music" section for now, though.
One other test to make - what happens if you re-run the OnLoad cutscene manually (by clicking "Run now" in the Inspector) after loading the Autosave?
Thank you for keeping at it, Chris, and sorry, I missed one piece of info - I changed the Max. number of saves from the default 5 to 3 in the Settings Manager (leaving the default 6 in both SavesLists, though), hence 3 save files only in the Save-game Manager, I guess. And here are the relevant in-game Save and Load Menus; the ones posted before were from the Menu Manager:
Here's the Music section of the Save 1 file:
Save 2 and 3 are identical:
I ran the test with the OnLoad Action removed from the Scene Manager.
Slot 1:
When loaded, plays music immediately, from mid-track as it was saved.
Ignores "Run now"; the current music just keeps playing.
Slots 2 and 3:
When loaded, there's no music.
"Run now" plays the music from the beginning of the track as intended.
So, the track you're trying to play is the track that's already playing?
If so, the music will just continue - you need to stop the music first by preceding the Action with another Sound: Play music Action that has a Method set to Stop.
Who would have thought! Such a simple and elegant solution, and it works beautifully. Thank you so much, Chris. You just made my day.
Greetings from London,
Jo