Share Blackboard across Agents with same Behaviour Tree

Forums 💬 NodeCanvas 🗨️ General Discussion Share Blackboard across Agents with same Behaviour Tree

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #13814
    jonc
    Participant

      Hi, so I’m almost done creating a custom editor function that sets up a lot of agents at once at the press of a button. The only obstacle left is how to automatically populate a blackboard.

      My NodeCanvas specific part in the “Setup Agents” editor script looks like this:

      This also adds the BB but of course it’s empty.
      Is there a way to save a BB preset and load it via code?

      #13821
      Gavalakis
      Keymaster

        Hello,

        Hmm. There are two possible solutions that I can think of for this.

        1) You can use the Blackboard API, to set the variables by code directly. For example:

        2) You could save a Blackboard variables to a serialized json string and store it somewhere, then deserialize the target blackboard you want, using that json. Some example code:

        You could of course also create some editor utility to save the json string to a file in editor only, like for example:

        Then in runtime you would need to of course have a reference to that saved TextAsset file and deserialize the blackboard from it’s contents. Once again, for example:

        Let me know if any of the above solutions works for you.

        Thanks!

        #13820
        jonc
        Participant

          Procedure 1 is exactly what I needed.
          Procedure 2 is also nice in the long run. Thanks to your code above I’ll be able to set up a nice compfortable editor function soon.

          Thanks for the help!

          #13819
          Gavalakis
          Keymaster

            You are very welcome 🙂
            I am glad that I could help!

            Thanks!

            #13818
            jonc
            Participant

              Greetings Nuverian,

              before starting another thread I ask this here…

              So I open the graph via editor script like this:

              This opens the Graph but not the Blackboard and all the node variables are gone or not loaded. How do I get the same behaviour as if I would click the “Edit Behaviour Tree” button on the inspector?

              The reason I want to get this to work is that my agents are full of components and this would be a welcome shortcut. 🙂

              #13817
              Gavalakis
              Keymaster

                Hello again,

                I am really sorry for the late reply. I got sick :/

                There are a few overloads for the ‘OpenWindow’ method. If you have a Blackboard already attached on the BehaviourTreeOwner in question, you can then use the overload that takes a “GraphOwner” instead. This will load the owner’s graph as well as the owner’s blackboard together in the editor 🙂

                Please let me know if that works for you.
                Thanks!

                #13816
                jonc
                Participant

                  Hi, I hope you’re well again…

                  I really should start checking overloads more often. Doing it the way you described worked of course.

                  Thanks once more!

                  #13815
                  Gavalakis
                  Keymaster

                    You are very welcome! 🙂

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