Share Blackboard across Agents with same Behaviour Tree

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

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #12735
    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?

    #12739
    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!

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

    #12741
    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!

    #12754
    Gavalakis
    Keymaster

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

    Thanks!

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

    #12755
    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. 🙂

    #12767
    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!

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

    #12769
    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!

    #12786
    Gavalakis
    Keymaster

    You are very welcome! 🙂

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

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