Integrating a shared blackboard on every behavior tree and task

Guerrilla705

New member
Hi! This may be a stretch, but I'm just curious if there's a good way to do this. I am using a blackboard since I have a bunch of other separate AI systems (sense, animation controller, navigation, etc.), and I'm not running all of the logic through tasks. Right now, I have a custom SharedAIBlackboard class which wraps my AIBlackboard class, and I assign this shared blackboard variable when I initialize the tree.

The annoyance is that I need to put a SharedAIBlackboard variable on every new action task, condition, etc. that I create, and every time I add an action or conditional to the tree, I have assign this variable to the tree's blackboard shared var. This is prone to error like forgetting to assign it on a newly added task leading to null reference exceptions that only crop up when the task is actually hit. Is there a way to integrate this base variable into every tree/task I create by default? I can create my own Action and Condition classes that inherit from BD's and have the blackboard there to avoid declaring it in every script, but that still doesn't solve the primary issue of assigning this variable on every task I create in a tree. I assume I would have to get into the actual C++ code to do this, which understandably isn't supplied (to my knowledge), so this may not be something that's possible. I figured it was worth asking!

Thanks for your time!!
 
One possible method would be to subclass all of the tasks that use this variable and then grab the reference at runtime. Something like:

Code:
override void OnAwak() {
    myVariable.Value = // Dynamically get reference
}

This will prevent you from having to assign the same variable within the tree for each task. The runtime source is available but in this case I don't think that you'll need it: https://opsive.com/downloads/?pid=803
 
Top