How are asset/unbound graphs supposed to be used?

NodeCanvas Forums General Discussion How are asset/unbound graphs supposed to be used?

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #15763
    dharma_42
    Participant

    I’ve been making AI agents in Unity with bound behavior tree graphs. However now that I’m spawning player and enemy AI agents at runtime, I like the idea of being able to edit one graph used by all of them. But of course these AI agents need to be able to use references to other scripts/data on their agent. How is this approached with unbound graphs? If this isn’t possible with unbound graphs, how are they supposed to be used with BTs?

    One easy option is to spawn the AI agent, and then bind the graph once its instantiated. How performance intensive is binding a graph at runtime like this?

    What’s the “right” or standard way to handle one graph used by many agents like this, but needs to be able to use BBParameters or refrences some other way?

     

    Thanks!

    #15783
    Gavalakis
    Keymaster

    Hello there,

    The main and most proper way to correctly utilize Asset Graphs, is by making their graph variables you need “Exposed Public”. You can make a variable “Exposed Public” through its “gear” icon menu. As soon as a graph variable is public hat way, it will have the following effects:

    1) If the Asset Graph is directly assigned to a BTOwner, you will see all its public variables shown in the inspector of that BTOwner and possible to change; per-owner.

    2) If the Asset Graph is used as a sub-graph within another parent graph, you will be able to “Map” the public graph variables of the sub-graph, FROM/TO the variables of the parent graph. This can be done through the inspector of the Sub-Graph node.

    Please let me know if the above is of help. 🙂
    Thank you!

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

    #15795
    dharma_42
    Participant

    <span style=”color: #323232; font-family: ‘Open Sans’; font-size: 12px; background-color: #fbfbfb;”>1) If the Asset Graph is directly assigned to a BTOwner, you will see all its public variables shown in the inspector of that BTOwner and possible to change; per-owner.</span>

    This way (#1) is what I’m looking to do. A few questions:

    1) Does the variables being “public to change” include binding them, or just getting & setting values?

    2) Are these BBParameters?

    3) Is there an example of this set up anywhere that I could look at? Any more info/guides/tutorials etc with this setup?

    4) Currently I have set things up so that the AI agent prefab assigns the BT to the BT Owner on Start() like so:

    But the way you describe in #1 doesn’t need this, right? Any code needed for that setup?

     

    Thank you for the help!!

    #15799
    dharma_42
    Participant

    Bump.

    #15808
    dharma_42
    Participant

    Since it looks like the code I included is messed up two posts ago, here it is (I can’t edit that post for some reason). I can’t upload a code snippet properly so I’ve attached a screenshot of it.

    Attachments:
    You must be logged in to view attached files.
    #15814
    Gavalakis
    Keymaster

    Hello again,

    1) “Public” graph blackboard variables can be bound to static properties/fields only.

    2) If you mean the ones shown in the “variables mapping” inspector, then yes, those are special BBParameters (BBMappingParameter -> derived from BBParameter).

    3) The setup is pretty easy 🙂 You just need to -Make an asset graph. -Make some of its variables “public”. -Use that graph as a subgraph in some other parent graph and Map the variables through the node inspector. I could send you an example if you need though.

    4) If the BT is already assigned in the BTOwner through the inspector then this is not needed (but it doesn’t hurt as well).

    Let me know if the above work for you.

    Thanks!

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

    #15828
    dharma_42
    Participant

    <span style=”color: #323232; font-family: ‘Open Sans’; font-size: 12px; background-color: #fbfbfb;”>If you mean the ones shown in the “variables mapping” inspector</span>

    … wait WHAT?! What is the variables mapping inspector? Where is it? This sounds like exactly the solution to my problem! I couldn’t find anything on it in the documentation or the website.

    I also could find absolutely nothing on exposed public graph parameters, namely how they’re supposed to be used. You should really consider adding some documentation on this stuff since its missing. 🙂

     

    Thanks!

    #15857
    Gavalakis
    Keymaster

    Hello again and sorry for the late reply!

    The “Variable Mapping” inspector can be seen on any “SubGraph” node inspector. If you add any subgraph node (e.g. Subtree) in a graph, you will see the variables mapping on that node inspector through which you can map the subgraph public variables (there is related help text there as well).

    You are right about the documentation. I do plan to update everything this month! 🙂

    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.