NodeCanvas Forums › General Discussion › Best Practice for Runtime Instantiation › Reply To: Best Practice for Runtime Instantiation
Hello,
Sorry for the late reply. I was on a trip out of office.
Yes, using the same Blackboard in more than one BehaviourTreeOwners means that all blackboard’s variables will be common. If you don’t want to do this then each BehaviourTreeOwner will need to have it’s own Blackboard.
Since the Blackboard is different than the BehaviourTree, why don’t you want to attach a BehaviourTreeOwner and a Blackboard component on all prefabs and assign the same BehaviourTree on all prefabs?
Another way, would be to add the blackboard at runtime on the instantiated gameobject through normal AddComponent(), initialize it’s variables through code by using blackboard.AddData(Type) and set it to the BehaviourTreeOwner .blackboard.
But I think it’s more managable to do it through the editor in the case that you do use prefabs.
Generaly speaking you can do prety much everything at runtime as well.
Here is some code too:
http://nodecanvas.com/documentation/runtime-instantiation-and-tips/
Let me know 🙂