BT not working in subscene

Stroopwafel

New member
Hello,

I tried to follow the entities sample by placing a cube in the subscene and add a behaviour tree to it. The BT only has a simple ECS Task in it where I added a Debug.Log() line in the job.

Nothing happens in the subscene altough the entity does have all the correct components during runtime (I believe). When I place the cube in the normal scene I do get the log fire.

I must be doing something wrong as its working in the sample scene, just cant figure out what it is...

Thank you for your time.

C#:
/// <summary>
/// Job which executes the task logic.
/// </summary>
[BurstCompile]
private partial struct MoveToPositionJob : IJobEntity {
    /// <summary>
    /// Executes the MoveToPosition logic.
    /// </summary>
    /// <param name="taskComponents">An array of TaskComponents.</param>
    /// <param name="moveToPositionComponents">An array of MoveToPositionComponents.</param>
    [BurstCompile]
    public void Execute(
        ref DynamicBuffer<TaskComponent> taskComponents,
        ref DynamicBuffer<MoveToPositionComponent> moveToPositionComponents) {
        for (int i = 0; i < moveToPositionComponents.Length; ++i) {
            var moveToPositionComponent = moveToPositionComponents[i];
            var taskComponent = taskComponents[moveToPositionComponent.Index];

            if (taskComponent.Status == TaskStatus.Queued) {

                Debug.Log("im here");

                taskComponent.Status = TaskStatus.Success;
                taskComponents[moveToPositionComponent.Index] = taskComponent;
            }
        }
    }
}
 
Found it. You need to enable the baked behaviour tree system. RTFM

C#:
// The behavior trees have been baked. Enable the system which starts the behavior trees.

BehaviorTree.EnableBakedBehaviorTreeSystem(World.DefaultGameObjectInjectionWorld);
 
Back
Top