Behavior Tree Extension - Select behaviors based on dynamic priority weighting.

Glad it’s helpful. Just don’t learn the bad habits too!

So just stumbled across this plugin after researching Utility AI for my project and I’m actually amazed that this is not a core part of the UE4 behaviour tree? Has anyone from Epic actually seen this? It takes your behaviour tree to a whole new level.

It was actually written while in discussion with Epic’s AI devs, with the intention of making a PR to incorporate it into the engine. So in theory they were happy to include it, but around that time they seemed to move away from engine work and have since been mostly tied up with Epic internal projects. Communication slowed down, then I realized I could implement it as a plugin so didn’t pursue the PR any further.

To be honest, although the AI guys were great, my current motivation to try to contribute engine improvements or feedback in any way to Epic is rock bottom. Nothing gets through anymore.
The plugin code is pretty minimal and has compiled without changes for the last few versions, so I’m happy to keep it updated, with Windows/Android binaries, for new engine versions.

Does the plugin incorporate any type of randomness?

Apologies, I completely missed this.

Yes it does. Essentially, you generate a utility value for each option, and then one is selected based on those values. There are two selection modes implemented, the first just chooses the option with the highest utility, but the other chooses semi-randomly with a probability proportional to the utility value. So using the latter setting, you can get behaviour that is random each time the tree is evaluated, but with some options being more likely than others.

Just wanted to say thank you for making this plugin. I’ve been reading Game AI Pro and making a lot early design decisions and knew I wanted to implement a utility selector. This fits perfectly!

One question though, and apologizes for such a noob question, what do you need to do to make a custom blueprint decorator (Burst or Time Based in the OP)? Is it just a matter of making a new decorator and returning a float value between 0 & 1? I guess what I’m trying to say is what value is the Utility Selector evaluating from the decorator?

The utility decorators are derived from a special class. You can either create one directly via adding a blueprint and specifying the base class, or if you’ve used the button inside the behavior tree editor, then you’ll need to adjust the parent class inside the blueprint’s Class Settings panel. Either way, the class you need to derive from is called BTDecorator_UtilityBlueprintBase. Under its list of function overrides, you should see CalculateUtility, which is where you can provide the value.

I should say here that after a discussion I had with someone quite recently about the plugin’s behaviour, it became apparent that it can’t properly support the various ‘Observer aborts’ functionality in UE4’s behaviour tree. This may or may not be an issue depending on the complexity and kind of behaviours you want to set up.

Hey @kamrann, Thanks for making this awesome plugin first off! Hoping to use it quite a bit!

I’m running into the exact issue your last post mentioned. I can’t abort self! This is really putting a damper on what I want to accomplish due to many of the nodes I need to use being blocking/synchronous, like MoveTo.

Do you think it would be possible for the Utility node to evaluate scores in Tick, and if the chosen decorator isn’t the current one, somehow inject a Fail event into the current decorator, or otherwise abort the decorator child tree and switch to the new one? This would only be applicable to the Priority selection mode, as Proportional would give you tons of popping around due to it’s random nature.

The only other option I can think of is to rewrite MoveTo and any other blocking task into a MoveToTick like function that would use a precomputed path (from service) and move one tick’s-worth rather than the entire path, which would allow the Utility node to re-evaluate. I have many worries with this approach, and it only solves one task at a time.

Thanks for any input you have on this! Really hoping to use this plugin to its full potential!

hey man i just found this plugin is it possible u make 4.24 version this one is really useful for me

I’ve added abort-self functionality (when using the Blackboard Key decorators) in a fork: GitHub - GSGBen/BTUtilityPlugin: Extension to engine behavior tree system, adding utility-based select