StartBakedBehaviorTree on Server return always false

daschnitza

New member
Hi,

I'm using Opsive Behavior Designer together with Unity Entities 6.4 and NetCode for Entities.

I have a entity that is spawned on the server from an ECS prefab:

Code:
Entity entity = state.EntityManager.Instantiate(
    entitiesReferences.entityPrefab
);
The prefab contains a Behavior Designer Behavior Tree.

I'm trying to start the baked Behavior Tree on the server with

if (state.World.IsServer()){
BehaviorTree.StartBakedBehaviorTree(state.World,entity);

The problem is that StartBakedBehaviorTree always returns false on the server.
I already checked that the entity exists with the components exist.
After checking the correct component, both the prefab and the instantiated entity have the
BakedBehaviorTree - Component.

Is there an additional initialization step or another required component/system for starting a Baked Behavior Tree on the NetCode ServerWorld?
Could StartBakedBehaviorTree require something that isn't automatically initialized when the entity is instantiated?

Or is there something specific that needs to be configured in Behavior Designer so that the baked Behavior Tree can run in a NetCode ServerWorld?

Any help would be appreciated.

P.S.
I disabled Start when Enabled because it also started on ClientWorld
 
Hello,

No additional Behavior Designer component should be added manually. The issue is that StartBakedBehaviorTree is being called too early.

BakedBehaviorTree is a temporary initialization component. StartBakedBehaviorTreeSystem consumes it, registers the tree’s task systems and component types, and, when Start When Enabled is disabled, adds DeferredBakedBehaviorTreeStart.

BehaviorTree.StartBakedBehaviorTree only succeeds when DeferredBakedBehaviorTreeStart is present. Calling it immediately after EntityManager.Instantiate therefore returns false because the automatic initialization system has not processed that new entity yet.

A server-only system can wait for the deferred component and then start the tree.

Justin
 
Back
Top