Persistent Blackboard

Forums 💬 NodeCanvas 🗨️ General Discussion Persistent Blackboard

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #14379
    atmuc
    Participant

      How can i use a blackboard as persistent between levels? can you add a feature like do not destroy on load level? i do not want to use unity preferences.

      #14383
      ironwolf
      Participant

        Hi

        I have a similar problem, and I would like to know what is the best aproach to achieve this.

        PROBLEM:
        I need some global settings to remain through levels. Let say I have a few scenes i.e.:

        • Settings – with GlobalBB
        • Level 1
        • Level 2
        • Level 3
        • … (and so on)

        At Settings screen I set some parameters to GlobalBB, and load further levels by standard Unity LoadLevel.
        Unfortunately on Level 1, 2 and so on I can’t set any reference to GlobalBB variables. I understand that – there is no such object in particular scene so it can’t get reference. So I make a copy of my GlobalBB to every single scene. It is not so hard when you make a Prefab. But that way every single scene have its own GlobalBB – it is local, and dosn’t really connected with Settings GlobalBB.

        Possible approaches:

        1. DontDestroyOnLoad

        In this approach on the first (Settings) scene I set GlobalBB object as DontDestroyOnLoad. When I LoadLevel this GlobalBB persist to next scene, and values are used properly, but trully there are two GlobalBB object now in evely Level scene – the local one which is set in the Level scene, and this persistence one from Settings scene. In play mode Unity warn me there is two BB with the same name. Although it works, but I don’t feel very comfortable with that – I’m not sure if it is stable solution or simply I have a luck and it is more random and uncertain which GlobalBB will be used?

        2. Save and Load BB between levels

        In this approach I don’t preserve Settings GlobalBB from being destroyed. Instead I save my GlobalBB parameters to PlayerPrefs before exit from particular scene, and load this parameters at the next Level . That way I have only one (local) GlobalBB at every scene, but the whole solution isn’t very convenient and is probably less efficient.

        3. Others

        I have some other ideas how to do it, but with heavily custom code which make it questionable to use GlobalBB at all.

        Summary:

        So I would like to ask the author once more – could you please specify what is the most proper way to achieve this with NodeCanvas2?

        BTW. plugin is absolutely great – I really appreciate it very much.

        #14382
        Gavalakis
        Keymaster

          Hello and thanks a lot!

          So, here is a solution with DontDestroyOnLoad which works nice and destroys existing GlobalBBs of same name.
          Please open up GlobalBlackboard.cs and change the CheckUniqueName methos on line #53 to the following:

          Let me know if this works for you.

          Thanks!

          (PS: @Atmuc. Sorry for the late reply. I have missed your initial post back on August 1 🙁 )

          #14381
          ironwolf
          Participant

            Thanks a lot – it works great – I hope it will be added permanently in the next update 🙂

            #14380
            Gavalakis
            Keymaster

              Hey.

              Glad to know 🙂
              Yes it will be added permanently 🙂

              Cheers!

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