How to combine two behavior tree components into one, which have the same behavior reference task

ffbh

New member
I've two separate behavior tree components:
Behavior tree components A has behavior reference task A which has the same shared variable name ("test_variable") as in the Behavior tree components A.
Behavior tree components B has behavior reference task A which has the same shared variable name ("test_variable") as in the Behavior tree components B.

It works well as all the components and external behavior tree use the same shared variable name ("test_variable");
Now I'd like to combine the two small trees into one big tree and I need to create two shared variables for the two small trees: "test_variable_A" for Behavior tree components A and :test_variable_B" for Behavior tree components B.
And here's the problem: How can I assign the specific variable to the behavior reference task? If I set the "test_variable_A" to the external behavior tree then it should work only for the part of Behavior tree components A.
 
I'm not completely following - can you give more detail? If two independent external trees have the same variable name then when they are joined in the parent tree that variable reference will be the same in both tree. If you assign a value within the first external tree that same value will appear in the other.
 
Yes, you are right, but that's the problem: I do not want to the two independent external trees use the same shared variable reference when they are combined into one big tree.

public abstract BaseSharedVariable {}
public class SharedVariableForComponentA : BaseSharedVariable{}
public class SharedVariableForComponentB : BaseSharedVariable{}

shared variable in behaviror tree componentA
name: test_variable type: BaseSharedVariable

shared variable in behaviror tree componentB
name: test_variable type: BaseSharedVariable

shared variable in external behavior tree which is used by behaviror tree componentA and behaviror tree componentB
name: test_variable type: BaseSharedVariable


At runtime I will assign the SharedVariableForComponentA to behavior tree componentA and SharedVariableForComponentB for behavior tree B and it works well.


What I'm going to do is merge behaviror tree componentA and behaviror tree componentB into one big behavior tree component.

shared variable In the big behaviror tree component:
name: test_variable_A type: BaseSharedVariable
name: test_variable_B type: BaseSharedVariable

At runtime I will assign SharedVariableForComponentA to test_variable_A and SharedVariableForComponentB to test_variable_B.

Then the problem occurs. if I change the name in external behavior tree from "test_variable" to "test_variable_A" then in the part of behaviror tree componentB the shared variable could not be inherited.
 
This would be a new feature request. Right now unless you name the variable something different there's not a way to have them behave independently. I'm not sure when I will be able to add this but the runtime source is available so you could make this change within Behavior Manager.
 
Thanks, I think I'd described this situation too complex, have read the doc and find the dynamic variable is maybe what I want. will update after I make sure the dynamic variable works.
 
Top