I have a combatant in my scene spawned with an "Add Combatant" component with "Remember Combatant" enabled. I've set up a script which autosaves the game every x seconds as well as manually at the conclusion of important events. When I load my scene, I check for the existence of an autosave file, and if it exist, I load that autosave. This approach works fine for most scenarios I've tried, but I've run into an issue with Add Combatant. When I reload the scene when an autosave is present, the "Add Combatant" will update BEFORE I load the autosave. Then when I do call the autosave the Add Combatant will not be updated. My guess is this is some sort of order of operations issue, like I need to load my autosave before the Add Combatant component initialized with the saved data first. For example if I load the autosave from a separate scene, it works fine (I suppose because the add combatant is not initialized before the autosave is loaded). Any thoughts on how I can address this issue without completely switching my approach to always starting with loader scene? For example, I don't see why when the autosave loads the Add Combatant does not update just because it has apparently updated before... shouldn't it just update again with the autosave data?

thanks,
-Mike
  • Did a quick test with saving/loading the game in the same scene and it seems to work fine.
    Can you give me details on how you handle the auto load?

    Loading the game should reload the scene.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Hi - thanks for the reply.

    I have my gameplay scene - this is the scene I run when I hit play and it's where I have the combatant spawned with "Add Combatant".

    I have a gameobject in this scene called Autosave Controller which has my custom autosave/load script.

    This script does three things:

    1) It has some Donotdestroyonload logic so that it there is only one instance of it despite it being present in all my scenes.

    2) Run a schematic ever x secs which runs the Autosave node

    3) In the Awake function, check if an Autosave file exists and if it does, run a schematic which runs the Autoload node.

    So the effect of this script is that the game is autosaving periodically and when I stop the scene and then hit play again it loads the autosave. As I said, this works okay for the player (if I level up for example, then stop the scene and replay, the player retains his level). But for some reason this does not work for the combatant spawned with Add Combatant. The data for this combatant IS correctly saved in the autosave file but what happens is this (I think): When the scene loads the combatant is correctly restored BEFORE I run the autosave load from my custom script. When I then run the autosave load, when the scene reloads, the combatant resets to its initial state.

    -MIke
  • indoflaven said: I have my gameplay scene - this is the scene I run when I hit play and it's where I have the combatant spawned with "Add Combatant".
    Is the combatant actually spawned (e.g. by ORK) or is this a game object already part of your scene setup?

    I also assume your auto save isn't run before awake, i.e. before auto load can kick in?
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Hi - apologies for my late reply.

    The gameobject is part of the scene and has the "Add Combatant" component.

    Correct, the AutoLoad schematic is called in Awake at default execution order (if an autosave exists)... Autosave is not called before this.
  • Can you send me a Unity test project with your setup to check out? Without your script and schematics I can only do similar tests and it works fine here.

    You can reduce the size of the project by deleting the Library folder - zip it up, upload it somewhere (e.g. dropbox) and send me the link to contact@orkframework.com.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Hi -
    In preparing to send you some files, I stripped this down to its simplest form and did a bunch of testing.

    I found that what I'm trying to do works if I call the Autosave load schematic the first time the Update function of my AutosaveController script runs. If I call the Autosave load schematic from the Awake function or Start function (I was calling it in Awake previously) it does not work. What I think may be happening (still just a guess) is either:

    -Combatant needs to be initialized from "AddCombatant" component before Autosave Load is executed

    -When Combatant is initialized from "AddCombatant" component, data loaded from Autosave Load is overwritten

    In any case - I think that running the Autosave load in the first run of Update will work for my purposes for now, but I will send your email with information about accessing my project if you'd like to take a look.

    Thanks,
    -Mike
  • I'll check it out - due to the scene reload (and data load) it shouldn't really matter if the combatant is initialized before or not.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.