Hi there!
How can I set a blackboard value (boolean) in behavior tree? Do I must create a task to do it? It seems dirty to me, to change it there. The boolean selects which parts of the tree should be executed so to me the most visible place to set it would be in a sequence after some task was completed, i.e. in a sequence after the task.
See picture:
To be completely clear: I know I can define a task, where I perform the “move to” operation and then set the blackboard value. All I would like to do is to set this value directly inside the beh tree graph.
I have here the getter (i.e. the blackboard condition) but no setter. I guess it is on purpose, but fail to see why.
By searching for “Get Value As…(bool, vector, int etc)” and “Set Value As…(bool, vector, int etc)”.
1 Like
To be clear, you don’t “Reset” blackboard decorators. The decorator determines if execution is “allowed” to pass through based on the condition. It is the equivalent of a “Branch” node in a regular blueprint. You wouldn’t “reset” a branch node would you? No, you change the variable’s value that the branch node reads. So in this case you are saying you ONLY want to execute that branch of the behavior tree IF “Reinit Is Set” ie…if the value of “Reinit” is TRUE. So as long as this value is true, you will then check and make sure the value of “Initial Location” is also true, and finally you will “Move To”. If any of those values change to be false, “Move To” will stop executing and fail up the tree.
1 Like
These “set Blackboard value as” nodes are available in any blueprint. Right? To execute the blueprint, I would need to define a task and add it in a sequence to the “move to” task. That is not what I was asking.
I would like to change the blackboard value visibly in the behavior tree. That cannot be done by the “set Blackboard value as” nodes, they are not available there.
So I guess it is on purpose, that changing blackboard values is done only in tasks (or services). My point is, that it would be clearer if one could set it straight in the tree (you know? seeing the node execution that changes it) where as now I must define a task and change values inside it.
1 Like
Also by looking at your behavior tree I feel like your AI would have issues “roaming” when the player is not seen. How do you set “initial location” and how do you change “initial location” when the AI has reached that point assuming they have not yet found the player?
Correct. And what I was saying is, the “decorator” that has a binary state of “is set” or “is not set” can’t be changed from one to the other because it isn’t a variable itself. It is the equivalent of a “branch” node and all you define is under what condition you would like execution to pass through. If you look to the bottom right of a running behavior tree you will see all your blackboard keys and their current value which does change during game play. That is how you can see what the value of your variables are. So what you are asking is odd because it’s treating the blackboard decorator as a variable instead of what it actually is which is a tool for flow control. I agree it would be nice to see what the value of the variable is the decorator responds to, but that would simply be an extra line beneath the “is set/is not set” to tell you the current value of the variable instead of having to check the right hand side and compare to the decorator. That however still wouldn’t change how the decorator handled flow.
Initial location is saved when i run the beh. tree from AI controller. It is like a constant the whole time. I guess I understand now, why there is no better shortcut than a task to change the value of blackboard. Thank you for your time!