Hi, I’m trying to create a system of behavior trees, whereby each subclass of a character utilizes the same root tree, but swaps out subtrees to change how the execute specific tasks (e.g. unique combat behaviors, but otherwise the same behavioral logic). After some testing, it seems as though dynamic subtrees will only run if the subtree provided has either the same blackboard as the root tree, or no blackboard at all.
I have two issues with this. One, it seems to be a silent, undocumented error that the engine should flag. Two, it would be nice if the subtrees could use a blackboard that inherits from the root tree’s blackboard. That way all of the information from the parent would still be available, but new fields could be referenced as well that are specific to that subtree.
How did you resolve this? I am currently investigating it also; it seems like it makes sense that an ability would have its own behavior tree with its own blackboard, but I don’t understand how that is supposed to be implemented…
I also ran into this issue and it has taken me a day, the result is very frustrating. I found this in the source code for “Run Behavior”
BTTask_RunBehavior.cpp
Where BlackboardData is the blackboard of the main behavior tree and OtherBlackboardData is the blackboard of the sub behavior tree. From this line of code, the UE (I used 5.3) main and sub behavior trees can only be the same blackboard, or the main behavior tree’s blackboard is child of sub behavior tree’s blackboard.
And for “Run Behavior Dynamic”
BlackboardComponent.cpp
bool UBlackboardComponent::IsCompatibleWith(const UBlackboardData* TestAsset) const
{
for (UBlackboardData* It = BlackboardAsset; It; It = It->Parent)
{
if (It == TestAsset)
{
return true;
}
if (It->Keys == TestAsset->Keys)
{
return true;
}
}
return false;
}
Where BlackboardAsset is the blackboard of the main behavior tree and TestAsset is the blackboard of the sub behavior tree. It’s same.I don’t know why UE doesn’t reverse them, now you just have to make a big big blackboard for all the behavior trees.