Forum rules - please read before posting.

Saving Global and Local Variables in AutoSave and Main Save

Hi, just for clarification, do I need to write a script to ensure my Global and Local Variables are saved? Or should AC remember them? I've consulted the Manual but I'm still a little confused...

Comments

  • All AC variables should be saved automatically.  If there is a related issue, please provide full details..
  • ok thanks, how do you ensure previous saves are removed on a new build? If i have saved in a build before, it seems that they persist in new builds?
  • On desktop platforms, saves are placed in Unity's Application.persistentDataPath and must be removed manually.

    The location of saves is printed in the Console when recorded.
  • Thanks, is it safe to delete the Library folder completely? I think unity crates a new Library folder with each build?
  • It's not for me to say - that's down to Unity.  I don't believe it is related to save game files, however.
  • The one thing I find that isn't saved from autosaving, is the last scene that was loaded upon entering the current scene, as this ensures where the player starts in the scene, let me explain:

    Player leaves Alley (Autosave on leaving) and enters Bay, due to last scene being Alley, Player starts at specific player start position in large scene. Upon quitting and loading, player is not at correct Player Start, and correct camera hasn't loaded for the start position either.

    Anywhere to rectify this?

    Thanks

    James
  • The contents of a save file will not vary with whether or not it's an autosave or not, but if you save at the wrong point it may be that the data is not used as you intend upon loading.

    Instead of autosaving when leaving Alley, try autosaving after entering Bay.
  • So I have implemented this, what seems to happen now is that if you save in the middle of a cutscene where the player cannot be controlled and reload, it starts where it left off in the scene but dead, and does not follow from where the cutscene left off. How best to get round this? Should saving not be allowed in a cutscene?
  • I autosave and overwrite existing data on every scene start
  • No - saving should not be allowed during a cutscene.  The default AC interface prevents this entirely, and the Manual's "Saving and loading" chapter details when saving is not allowed.

    The Save: Check Action can be used to determine if saving is possible at any moment.
  • Yes, you are correct. I have now just ticked autosave after cutscene box (and every OnStart) where i want to be sure autosave has captured an event to save the user doing it again if they don't manually save. I have removed the autosave action list from cutscenes.
  • AC 1.64.5
    Unity 2018.2.8f1

    So, I am still having massive problems with autosave. 

    Some of the same scenes are visited regularly throughout the game, in different scenarios. IE the player visits the same scene in part 1, 2 and 3, with different characters and objects depending on the specific section of the game.

    My OnStart cutscene is set to 'autosave after', to ensure that once the scene starts, the players progress is captured. However, when the player visits the same scene in part 2 or 3 and the player loads the last autosave. It seems that a mish mash of part 1 and 2, 3 etc is implemented on play. Even though all my objects have remember visibility, transform and hotspot scripts on where relevant.

    So I have some questions about 'Autosave after'.

    If I have 'Autosave after' on my OnStart, but have separate cutscenes for Part 2 and 3 within the OnStart cutscene in that scene, should they have 'Autosave after' on them too, or will this confuse things? Should 'Autosave after' only be implemented to cutscenes within the OnStart rather than 'Autosave after' on the OnStart?

    Or, should having an 'Autosave after' on the OnStart cutscene capture the changes implemented,emnted in Part 2 and 3 cutscene if they are within OnStart?

    I currently just have 'Autosave after' on the OnStart of each scene. But this is not capturing the correct start for when the player loads Autosave.

    I tried using action list:Autosave, but this just caused problems, and as they were within the cutscenes they were ignored anyway. 

    Or, would it be simply better to rename the scene, and have 3 different versions relevant to Part 1,2 or 3, and only have the objects characters, variables related to that scene? With a 'Autosave After' on the OnStart of each version of the scene? Would this rectify it?

    I have looked at the manual but this hasn't helped.

    Thanks

    James
  • You give no detail on what exactly the problem is - i.e. what data is loading incorrectly.  It is also not clear on how you are calling "part 2/3 cutscenes" within your OnStart.

    The Autosave after? option should be used on the Cutscene that features the Action that is the last to be run before gameplay resumes.

    If you want to use the Save: Save or load Action, you can do so from an ActionList that is running in the background.  Try creating a new Cutscene set to run in background, and give it that single Action.  At the end of your intro cutscene, run that new one separately and it should allow you to save.
  • Hi,

    So please see structure of my OnStart Cutscene and how I call Part 2 and 3. 

    I'm still a little confused on the Save aspect. When you say the Action that is the last to be run should have the Autosave after? on, then surely if my Part 2 and Part 3 cutscenes are within the OnStart, then the OnStart is always the first and last cutscene to be run before gameplay resumes, encapsulating all cutscenes with it, whether they are called or not?

    See screenshot here:

    https://www.dropbox.com/s/69v2sikl7my3284/Screenshot%202018-09-25%2008.47.25.png?dl=0

    Thanks

  • I can't tell from this - you're cropping the screenshot and not showing the other cutscenes.

    Unless you use the ActionList: Run Action with Wait until finish? checked, the ActionList it's called from will not necessarily remain active for its duration.

    If you display the AC Status box at the bottom of the Settings Manager, you can see what ActionList is running at all times.
  • Not sure if this is relevant, but you seem to be saving many times whether progress has been made or not? Would it help to focus more on isolating progress checking to global variables? Each scene can check the relevant variables and set the scene up dependant on puzzle progress. In theory, you should be able to go through the entire game without any saves, or just save once anywhere, and the game will return to that state simply by checking variables. As an example I have an NPC named Izzy. I have a global variable named Izzy. If that var is set to 0, that means she is still in bed. Any scene where she might appear, removes her at load if the variable is 0. 1 means she has been woken up and should be sitting in the dining room. In this instance, on load of her bedroom, it checks Izzy var, finds it as 1 and removes her from the scene. Dining room scene startup sees 1 and leaves her in place at load. I then have a 2 to mean she's wandered off to her room to play Xbox. Dining room removes the NPC. Bedroom moves the NPC to the TV and changes her animation. I might actually be doing this the wrong way, but I'm tracking my global variables in YED, alongside my puzzle dependency chart so know exactly what each variable value means. Kev
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.