Hi,
I have problem with setting External Behavior Tree at Runtime. I am using pool for my Enemies prefabs. Also I use pool for External trees. The problem I have is that my Tasks / Actions reference to old game object from pool.
This is how I set up External tree:
The problem is that in my action:
Is there any way to force change gameObject in tasks of entire tree?
I have problem with setting External Behavior Tree at Runtime. I am using pool for my Enemies prefabs. Also I use pool for External trees. The problem I have is that my Tasks / Actions reference to old game object from pool.
This is how I set up External tree:
C#:
BehaviorTree.DisableBehavior(true);
BehaviorTree.ExternalBehavior = PreloadedBehaviourTrees[behaviourType].GetExternalBehavior(actor);
BehaviorTree.EnableBehavior();
The problem is that in my action:
C#:
[TaskCategory("Actions - Enemies")]
[TaskDescription("Text")]
public class EnemyAi_Shoot : Action
{
EnemyAi_Container _enemy;
[BehaviorDesigner.Runtime.Tasks.Tooltip("Instant Fire")]
public SharedBool Instant= false;
public override void OnAwake()
{
_enemy = gameObject.GetComponent<EnemyAi_Container>(); // gameObject is reference of old enemy gameObject after respawn from pool
}
}
Is there any way to force change gameObject in tasks of entire tree?