How to use "GetComponent<BehaviorTree>()" to get a certain group on a GameObject?

snowtv

New member
If I have multiple "BehaviorTree" component on a single GameObject, but each of them has a different group, how can I get the specific BehaviorTree component from a script?
 
You can check the grouping variable with:

Code:
var behaviorTrees = myGameObject.GetComponent<BehaviorTree>();
for (int i = 0; i < behaviorTrees.Length; ++i) {
   if (behaviorTrees[i].Group == myGroup) { DoSomething() };
}
 
Top