I have a problem. In the picture below the Service (1.) looks to see if the player has invalidated the cover the agent is currently in. It does this fine using a tick. This flips the state that the decorators at 3. use to decide which branch to progress down.
The problem is is that, unlike a traditional behavior tree where this pattern would work fine, with ue4’s implementation control doesn’t return to the selector at 4. until the sequence (2.) has finished.
I need to be able to interrupt the AI on many different events and instantly switch to another branch. I’m sure there is a way and I’m just not used to this paradigm yet. How would I do this?
I’m thinking I probably need to send a message to the tree to re-evaluate from the root as soon as the service detects the invalid state, just trying to figure out how now.
So the answer to this is to mark the decorators at 3. to abort their current sub-tree when the condition they are watching changes.
Like this:
This way when the Service changes the value of the state, the decorator will re-evaluate and fail. This is actually a really nice pattern because it means you only re-run what you need to.
This event-driven approach is one of the things unique to UE4’s implementation of Behavior Trees. I’m really glad you find it useful and I’m sorry we’re not emphasizing this pattern enough in the documentation.
Not the only part of the documentation that is pathetic, unfortunately. By far not. Many parts lack any kind of explanation, it’s basically telling you “Yes, that field exists. Figure out by yourself what it does.” I repeatedly had the feeling that about 75% of the documentation was done by some apprentice who either had no idea himself, or was too lazy to write the tiniest explanation.
to play the devil’s advocate a little, it is dauntingly vast what they do already, and i suppose their most valued devs will not be tasked with writing the documentation. I think?