I know about basic BehaviourTrees using selectors and sequencer. But I am confused about the use of Services and Decorators, what are they used for exactly?
If they can execute functions, then what is the use? Tasks?
I know about basic BehaviourTrees using selectors and sequencer. But I am confused about the use of Services and Decorators, what are they used for exactly?
If they can execute functions, then what is the use? Tasks?
Hi ,
Have you had a to look at our Behavior Tree Quick Start Guide? That will provide some basic information for you, and steps 9 - 10 should help with your questions about Services and Decorators.
Ok thanks, I got another question.
If I want to write task, services and decorators in c++, which base classes should I use and which of their respective functions?
Till now, I am just sure of 1 of them thanks to a guide written.
For Tasks, we can extend from UBTTask_BlackboardBase
and
virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent* OwnerComp, uint8* NodeMemory) const overrride;
function is used to perform the task.
I have found similar classes.
i.e UBTService_BlackboardBase and UBTDecorator_BlackboardBase
But not sure if they are correct and which function should I override to perform the necessary tasks?
In general you can derive from any class starting from UBTTaskNode
, UBTDecorator
and UBTService
. The _BlackboardBase
versions contain additional code for handling blackboard, but you don’t have to use those (although it’s recommended to use blackboard for AI-to-BT communication).
Regarding “what to override”, just read the code, look for virtual functions, read the comments. It all depends on what you want to achieve. As a rule of thumb I can only suggest overriding as little as possible and always call super implementations
And you can always look at implementation details of other natively implemented BT nodes
Hope it helps!
Cheers,
–mieszko