I'm using StartBehaviorTree task to start child trees and I'm using the synchronize variables tick box. I believe this only syncs the variables on the way into the sub tree. It would be great if it syncronized back to the parent tree when the sub tree completes. Can I do this or is there a better way to do this?
C#:
public override void OnEnd()
{
if (behavior != null && waitForCompletion.Value)
{
var variables = behavior.GetAllVariables();
if (variables != null && synchronizeVariables.Value)
{
for (int i = 0; i < variables.Count; ++i)
{
Owner.SetVariableValue(variables[i].Name, variables[i]);
}
}
behavior.OnBehaviorEnd -= BehaviorEnded;
}
}