Trying to get a BehaviorTree variable on a GameObject with multiple Behavior Trees

JasonT

Member
I'm using this:
C#:
 public BehaviorTree TargetBehaviorTree;
var vector = (SharedVector3)TargetBehaviorTree.GetVariable("CurrentAcceleration");  //get CurrentAcceleration from BehaviorTree variable
currentAcceleration = vector.Value;

But the variable I'm looking for CurrentAcceleration is on the 5th BehaviorTree of that GameObject. Is it possible to specify a specific BehaviorTree when there are multiple trees on a GameObject?
 
Yes, you can use the grouping property on the behavior tree component in order to get a unique tree.
 
Just need a little more clarification.

So if I declare a public BehaviorTree variable and drag in a GameObject holding a bunch of behaviorTrees to the inspector, it will only reference the Group0 BehaviorTree script?

So if I want to access a specific group I will need to instead drag in a public GameObject and do something like FindAllObjectsofType(Behavior) on that GameObject and then loop through the array and compare the Group property for the one I want? Or am I missing something obvious?
 
do something like FindAllObjectsofType(Behavior) on that GameObject and then loop through the array and compare the Group property for the one I want
Yes, that's one way. Within the Movement Pack's demo scene I do something similar in order to determine which tree to enable/disable.
 
Top