Understanding Blackboard Internal Variables Behaviour Save/Load BB

NodeCanvas Forums Support Understanding Blackboard Internal Variables Behaviour Save/Load BB

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #13103
    Lolitowww
    Participant

    Hello! I’m a new flow/node canvas user here and i’m enjoying a lot the tool. But Ive a little problem and im looking for help. I’ll try to explain myself as well as i can (using non programmer language).

    Im trying to save/load blackboard variables with the save/load task on nodecanvas.

    My Issue here is that the internal references of the BB (on debug) changes during the gameplay and when I save with the task in the BT The “saved” information contains the current “internal references” When I destroy the object that contains the BB and I instanciate it again from a prefab, the internal references of the BB goes back to original and when I load into a BB that comes from a prefab, the internal references are different (from the version that was saved) and the values don’t point to the same “slotS” anymore, giving in result a exchange of references and making the game to get errors.

    I’m adding a video explaining the problem visually. https://drive.google.com/open?id=1XAUOuvU4ZyJ-VAq_g-I7G8cmOgLA4P6f

    I’m not sure if i’m doing something wrong on the way i add elements to list or destroy object etc, is that the expected behaviour of the BB and the Save/Load command? It is possible to save BB information and make the “internal references” of the BB always be the same to be able to “continue a game” for example?

    Thanks!

    #13104
    Lolitowww
    Participant

    I Forgot to mention that i’m currently using 2017.4.0f1 and Nodecanvas 2.8

    #13105
    zsoik
    Participant

    Probably similar to https://nodecanvas.paradoxnotion.com/forums/topic/global-blackboard-access-exceeds-global-blackboard-lifetime/ ? I’ve got the issue that Deleting/Recreating a global blackboard with the same names will retain references to variables in the original (deleted) blackboard. There was no proper workaround but to just keep the blackboards alive all the time.

    #13116
    Gavalakis
    Keymaster

    Hello and welcome.

    I am glad you like the tools and thanks for the video explanation.
    Even though your video and your post was very thorough, I am not exactly sure what you want to achieve ( my bad not able to understand and very sorry about that 🙁 )

    Are you trying to save references to the runtime instantiated objects and then load them back, or is the problem only the fact that the internal references array is changing and messing up the original references?

    If you are trying to save/load runtime instantiated object references, this is something that is not really possible because these runtime instantiated objects, don’t have anything (some data for example) by which they can be referenced, since they will first need to be instantiated to get a reference to them. Even in “standard” save/load situations in Unity (eg non-NodeCanvas), you wouldn’t store a runtime instanced object reference. You would instead store some other data in basic variable types (like strings or integers) and based on those data instantiate the necessary objects (scene or prefab references) to re-create the state of the game at that time when loading the “save”.

    If I indeed misunderstood and the problem is only the fact that the “internal references” array is getting messed up on save/load due to the different object references that have been added in the blackboard in runtime, but you only want to save/load a few of those variables (like for example the integers like Food, Total, Money, Prisoners etc), then one solution would be to separate the data into two Blackboards, one Blackboard being for only the data that you want to save/load and another Blackboard being only for the non-saved static/persistent as well as temporary variables required for your game to work, like for example DiscardSlot, UI, SpawnOrigin, CurrentEventPrefab (if I am not mistaken).

    Thinking about this a bit more, I could probably make an update by which to make it possible within a Blackboard to select which variables are to be saved/loaded with a checkbox and which ones to leave untouched.

    Did I completely misunderstood your question and the problem you are facing? I am sorry if that is the case.
    I don’t know if @zsoik‘s case and solution is relevant, but I think it is a bit of a different situation.

    Please let me know.
    Thank you!

    Join us on Discord: https://discord.gg/97q2Rjh

    #13132
    Lolitowww
    Participant

    Hi!
    Thanks for the reply, i understand is provably was hard to understand beacause the explanation was not great and thats why i did the video to help.

    Regarding to the problem, What i want to do is Save a list of referenced prefrabs (not instanciated) and them instanciate from there. This list will be used as a “deck” where the game will instaciate cards. So i want to save the status of the game this way the player will be able to continue later on.

    So the question here is… Can i save a BB with many list of prefabs/scriptableObjects methods? I tryied to just create a BB for storing these list but i cant make it work. When I add elements to the list and “save” on the debug inspector i see the references but when i Load the list length is correct but contains no items.

    #13146
    Gavalakis
    Keymaster

    Hey,

    Sorry for late reply! So, to be able to save a list of references which list is going to be populated in runtime within the game, the way to correctly save that list and references, is to have all the references that are potentially going to be part of your list already stored somewhere within the same blackboard. This is required so that your “deck” list, knows what those references are.
    This can be done, by having a list “AllReferences” and putting into that list all the potential references, and another list “Deck” which you modify, save and load in runtime.

    I have made a video for you showing what I mean 🙂
    [VIDEO LINK HERE]

    Please let me know if that was clear.
    Thank you.

    Join us on Discord: https://discord.gg/97q2Rjh

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.