Decorator update

krides

New member
I would like to have a decorator update every frame – at the same frequency as the task it's decorating. But it looks like the Decorate function only updates when the child finishes execution, and OnUpdate isn't called on the decorator at all. What is the right way to do this?

C#:
namespace BehaviorDesigner.Runtime.Tasks
{
    public class EnvQueryEvalDecorator : Decorator
    {
        public SharedEnvQuery envQueryRef;
        public SharedGun gun;
        public SharedBool evalResult;

        public override TaskStatus Decorate(TaskStatus status)
        {
            evalResult.Value = envQueryRef.Value.IsCurrentPointGood(envQueryRef.Value.defaultEQSParams, gun.Value.checkVisibility);
            return status;
        }
    }
}
 
The decorator does not have a callback which updates every frame. Right now you would need to import the runtime source and make the modification to the behavior manager in order to add support for it.
 
What is the recommended way of doing things like this then? I'm just trying to have something execute at the same time as something else, but it's not a behavior, just some evaluation.

In other implementations of Behavior Tree, this is what a Service or Decorator would be used for (e.g. UE4). Currently, I have a monster Parallel with two Repeat decorators, and this functionality in a Task node, but it seems wrong.
 
You could have a Parallel task at the root, and then have a new action task which does the execution every frame within OnUpdate.
 
Top