Can access blackboard variables

Forums 💬 NodeCanvas ⚙️ Support Can access blackboard variables

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #15280
    gotenxds
    Participant

      Hi, I’m very very confused by the blackboards, it seems like there are 3 independent blackboards running for one graph and I just cant seem to access each of them.

      Setup:
      I have an asset behavior tree which I have a int variable on, I then set that value to be something else with an action.

      When calling GetComponent<Blackboard>.variables I get an empty list – the variables are not there
      When calling GetComponent<GraphOwner>.blackboard I get null, there is no blackboard at all

      In the action, the set operation does work, and if I call blackboard.variables I get a list on 1 item, the variable is there
      however if I call (in the action) blackboard.propertiesBindTarget.gameObject.GetComponent<IBlackboard>().variables I again get an empty list, that is it is a different blackboard, what is going on, how do I get access to the variable I set

      #15281
      Gavalakis
      Keymaster

        Hello,

        There are 2 different blackboards you can access. One is the Blackboard component attached to the GraphOwner gameobject, and the other is the local Blackboard of the graph itself, the “Graph Blackboard”.

        Both the ‘GraphOwner.blackboard’ and the ‘Task.blackboard’ properties (in actions and conditions) correspond to the gameobject Blackboard component that is assigned in the GraphOwner inspector (by default it is the same as the one attached to that gameobject). Please check if the blackboard parameter in the GraphOwner component inspector is assigned.

        Only the ‘Graph.blackboard’ property corresponds to the graph’s local blackboard.

        With that said, the easiest and more proper way to directly access your variables in either case (other than linking them to BBParameters fields in Tasks), is simply by using the GetVariableValue and SetVariableValue methods, like for example from within an Action Task:
        blackboard.GetVariableValue<int>("myNumber"), or blackboard.SetVariableValue("myNumber", 12).
        These methods will get/set the appropriate variable (matched by name and type) in either of the two Blackboards (gameobject Blackboard and graph Blackboard).

        Please let me know if that works for you.
        Thank you.

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