Alright, it took me literally days to track down this issue -__-
I guess I will provide some screenshots that make it easier to understand
This Error appears when I am trying to swap External Trees using following code
this.GetComponent<BehaviorTree>().ExternalBehavior = GameObject.Find("TreesBehavior").GetComponent<TreesBehavior>().getTree(TREE);
I literally tried everything before and after with all kind of combinations,even calling the upper code from other GameObjects that are not attached to BehaviorTree etc.
this.GetComponent<BehaviorTree>().StopAllCoroutines();
this.GetComponent<BehaviorTree>().DisableBehavior();
this.GetComponent<BehaviorTree>().enabled = false;
Tried calling in
public override TaskStatus OnUpdate()
or
public override void OnStart()
Nothing works.
The error seems not to be crucial because everything still works fine but the Error is pretty annoying because it Spams my console full.
The funny thing is, this error only happens when the upper code is executed within or below a Sequence that has a "Return Success". I assume there are more possible combinations and I am pretty sure an "Inverter" will lead to the same situation (not tested).
However, if you move the Swap Tree outside that Sequences into a Sequence that has not "Return Success", there is no error
Full Code looks like this right now but as I said I tried literally any kind of combination
public TreesBehavior.Tree TREE;
public override void OnStart()
{
this.GetComponent<BehaviorTree>().StopAllCoroutines();
}
public override TaskStatus OnUpdate()
{
this.GetComponent<BehaviorTree>().DisableBehavior();
var tree = Object.Instantiate(GameObject.Find("TreesBehavior").GetComponent<TreesBehavior>().getTree(TREE));
tree.Init();
this.GetComponent<BehaviorTree>().ExternalBehavior = tree;;
this.GetComponent<BehaviorTree>().EnableBehavior();
this.GetComponent<BehaviorTree>().enabled = true;
return TaskStatus.Success;
}
A fix or a solution would be very appreciated.
Sometimes not sure when I get this error instead of the upper one
ArgumentOutOfRangeException: Argument is out of range.
Parameter name: index
System.Collections.Generic.List`1[System.Collections.Generic.List`1[System.Int32]].get_Item (Int32 index) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:633)
BehaviorDesigner.Runtime.BehaviorManager.RunParentTask (BehaviorDesigner.Runtime.BehaviorTree behaviorTree, Int32 taskIndex, System.Int32& stackIndex, TaskStatus status)
BehaviorDesigner.Runtime.BehaviorManager.RunTask (BehaviorDesigner.Runtime.BehaviorTree behaviorTree, Int32 taskIndex, Int32 stackIndex, TaskStatus previousStatus)
BehaviorDesigner.Runtime.BehaviorManager.Tick (BehaviorDesigner.Runtime.BehaviorTree behaviorTree)
BehaviorDesigner.Runtime.BehaviorManager.Tick ()
BehaviorDesigner.Runtime.BehaviorManager.Update ()
I guess I will provide some screenshots that make it easier to understand
This Error appears when I am trying to swap External Trees using following code
this.GetComponent<BehaviorTree>().ExternalBehavior = GameObject.Find("TreesBehavior").GetComponent<TreesBehavior>().getTree(TREE);
I literally tried everything before and after with all kind of combinations,even calling the upper code from other GameObjects that are not attached to BehaviorTree etc.
this.GetComponent<BehaviorTree>().StopAllCoroutines();
this.GetComponent<BehaviorTree>().DisableBehavior();
this.GetComponent<BehaviorTree>().enabled = false;
Tried calling in
public override TaskStatus OnUpdate()
or
public override void OnStart()
Nothing works.
The error seems not to be crucial because everything still works fine but the Error is pretty annoying because it Spams my console full.
The funny thing is, this error only happens when the upper code is executed within or below a Sequence that has a "Return Success". I assume there are more possible combinations and I am pretty sure an "Inverter" will lead to the same situation (not tested).
However, if you move the Swap Tree outside that Sequences into a Sequence that has not "Return Success", there is no error
Full Code looks like this right now but as I said I tried literally any kind of combination
public TreesBehavior.Tree TREE;
public override void OnStart()
{
this.GetComponent<BehaviorTree>().StopAllCoroutines();
}
public override TaskStatus OnUpdate()
{
this.GetComponent<BehaviorTree>().DisableBehavior();
var tree = Object.Instantiate(GameObject.Find("TreesBehavior").GetComponent<TreesBehavior>().getTree(TREE));
tree.Init();
this.GetComponent<BehaviorTree>().ExternalBehavior = tree;;
this.GetComponent<BehaviorTree>().EnableBehavior();
this.GetComponent<BehaviorTree>().enabled = true;
return TaskStatus.Success;
}
A fix or a solution would be very appreciated.
Sometimes not sure when I get this error instead of the upper one
ArgumentOutOfRangeException: Argument is out of range.
Parameter name: index
System.Collections.Generic.List`1[System.Collections.Generic.List`1[System.Int32]].get_Item (Int32 index) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:633)
BehaviorDesigner.Runtime.BehaviorManager.RunParentTask (BehaviorDesigner.Runtime.BehaviorTree behaviorTree, Int32 taskIndex, System.Int32& stackIndex, TaskStatus status)
BehaviorDesigner.Runtime.BehaviorManager.RunTask (BehaviorDesigner.Runtime.BehaviorTree behaviorTree, Int32 taskIndex, Int32 stackIndex, TaskStatus previousStatus)
BehaviorDesigner.Runtime.BehaviorManager.Tick (BehaviorDesigner.Runtime.BehaviorTree behaviorTree)
BehaviorDesigner.Runtime.BehaviorManager.Tick ()
BehaviorDesigner.Runtime.BehaviorManager.Update ()