Behavior tree, Selector always executing the first Black Board

Hello,
I’m facing an insue on my behavior tree, when a NPC spwans in world the BT always executes the first black board (inside the yellow circle), even when it faills, then executes the right one. It’s supposed to execute onle the one chosen by the service in the selector. After couple secounds the tree execute correctly and the first one doest not executes, unless it succeeds.

I’ve checked using the recurse of “print” inside the service and the right task is chosen since the beggining of the spawn.

Someone khows how to fix this? or is it a bug?

The selector will always run the tasks below, starting on the left. I assume, your service sets the value for NPCWorkChoice depending on some logic. If your service is yet not run, when the bt starts, there’s some value in the NPC_WorkChoice, looks like it is Lumberjack, so that the left tree is run, before the service runs the first time.
What I like to do is to access the blackboard value before running the BT. This allows to set values, then start the BT. I’ll have a look at some example…

In your AI Controller, do not run the BT yet. First do a Use Blackboard in BeginPlay.

grafik

This allows to set well defined values for critical variables.

After this is done, start the BT as usual

grafik

I use this approach which offers more control before kicking off the Logic.

It’s exacly what you explained. The plobem is the NPC_WorkChoice is an enum value so i can’t clear the value and it always begin on index 0 that’s Lumberjack. The solution i found was make the 0 index a “Empty Work” and the Blackboard will just force the NPC wait a bit on every BT start.