AI Behavior Tree - Service or Task? how to choose?

TL;DR: What are the guidelines to create a service vs a task for a specific action?

I’m looking into Behavior Tree and I’m looking into some guidelines on when to use a service vs task.

For example, I was thinking on using a task to find the AI enemies (like the player), using a perception component.
I then looked at the ActionRPG example, and noticed they have a service to doing something like that.

I then thought perhaps it’s about an actual action (like moving) vs updating the blackboard. But I found a node in the same ActionRPG example
with a task for “Finding new location round target”, which is the same thing.

So what is it? What are some points/guidelines that can help one decide if he should use a service or a task a behavior tree?


Have you seen what the documentation has to say about the issue? Maybe there is a snippet in there that clarifies the best way of implementing your idea. Unfortunately, I personally do not have an answer for you.

Yup, looked already. Tried to look all over the documentations and examples.
There doesn’t seem to be any guideline as far as I can tell, and I’m not really sure when to use which.

The service is to get information that is then used to make decisions: “Finding new location round target”, “low hit points?”…

The tasks are more the physical actions of the character: “Move to target”, “Use health potion”…

Services best sit on the selector or sequence nodes. They are good at making calculations on that node.
Tasks do exactly that.

Services biggest thing is that they can run parallel, like you can have an AI run via a task and shoot via a service.