Behaviour trees and agent sensors

Assume I have a behaviour tree like the following:

    [A]
/ | \
[B] [C] [D]

• A = Selector (Priority node)
• D = Walk to point task

The reason the tree looks like this is because B has priority over C and D since it should trigger alert procedures. In short, what I'm trying to model here is that the Agent sensors must have priority over behaviours.

Assume now the agent is in D and this node will continue returning running until the destination point is reached.

While D is running, something might happen (for instance, the NPC see or hear something) that should break the current operation as soon as possible but, D will go on regardless until it's done.

I know I could paste the sensors code on top of each tree leaf, like for example:

// kinda javaish pseudo code
void run() {
// The node running method
return this.fail();
}

// Else, keep going.
if (! this.reachedGoal()) {
// do the walking
return this.running();
}

return this.success();
}


But with that solution the "alert" behaviour is hard coded and out of the tree logic.

What solution do you suggest?

• Are you using some library or framework for the implementation of the BT? Are you building your own BTs? – Leo Mar 6 '18 at 15:29
• I was using an external library. I think i ended up coding a custom composite node type with the purpose of intercepting each tick and running the appropriate sensors – brazorf Mar 7 '18 at 9:30
• I added a behavior-tree tag :) I agree, I found it strange too. – SashaZd Nov 11 '19 at 19:26