Download

What is the best way to retrieve values from Blackboard in BT task/service

In my Behavior Tree I use a Blackboard with some variables, a few of them I need in multiple tasks and services of that BT. I wonder what is the best way to deal with this? By now I need to create a local variable in the task’s or service’s BP and a Blackoard Key Selector. Then in the BT itself I set the key selector to the according Blackboard variable. Then in each BP I do the following (in this example “Firefly” is the local reference variable and “Firefly Key” is the Blackboard Key Selector):

Blackboard.png

Ok, that works. However it also feels quite cumbersome, in particluar since I need to do all of that in every single BP in which I make use of the Blackboard variable. Now I am wondering, isn’t there an easier way to retrieve and store Blackboard variables form within a BT task/service BP?

No ideas whatsoever?

i dont know what exactly u are doing here / what you want to do. so its really hard to help.

for values that every task in a BT needs acess to you can assign a blackboardvalue. every task can retrieve those from blackboard key selector variables

idk whats your problem with it, its as simple as it can be. i also dont know why seem to want it to store in a variable again and cant help if i dont know what you want to do exactly.

Ok I try to explain it in other words. Say I want to make use of a reference to an object stored as variable in the blackboard. To use that reference in every tick of a BT service or task I need to read it from blackboard. For better performance I want to retrieve the reference once and save it into a local variable.

This includes several steps:

  • Create a blackboard key selector (to access the blackboard variable)
  • Create a local reference variable (for the object I want to access)
  • In every tick check whether the reference variable has been set
  • If not, read it from blackboard via the key selector as object
  • Cast the object to the real type
  • Sae it into the local variable

So all in all this is quite a number of steps involved. Now I wonder whether this is really the best way to handle this. Am I missing something here?

Its easier to check if something “is set” with decorator nodes.

Also you dont need to cast since the object is already that object. (if you do not set the variable to “firefly type” but to actor or object)

Im not i am not even sure if the performance is that much better if you do it that way, i dont think getting the variable from the blackboard is a big deal.

If casting is a must. That will make the task has dependency with the blackboard. Which is not really good in my personal perspective.
for the function Get/Set value as Object or Vector, what if I have more than one parameter with the same type. I wonder which one will it be?