# Should the Behavior Tree Task or Decorator Break out of a Task that Runs Over Several Frames?

**URL:** <https://forums.unrealengine.com/t/should-the-behavior-tree-task-or-decorator-break-out-of-a-task-that-runs-over-several-frames/1145272>\
**Category:** AI\
**Tags:** Behavior-Tree, unreal-engine, question\
**Created:** [April 26, 2023, 5:05pm UTC](https://forums.unrealengine.com/t/should-the-behavior-tree-task-or-decorator-break-out-of-a-task-that-runs-over-several-frames/1145272 "2023-04-26T17:05:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JoeProgram](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/joeprogram/32/872486_2.png) [@JoeProgram](https://forums.unrealengine.com/u/JoeProgram)\
**Post date:** [April 26, 2023, 5:05pm UTC](https://forums.unrealengine.com/t/should-the-behavior-tree-task-or-decorator-break-out-of-a-task-that-runs-over-several-frames/1145272/1 "2023-04-26T17:05:09Z")

</div>

Hello! Unreal newbie here.

![berries](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/6/b/66bea99a3c3ab64aa619753b16ed08af20680fc2.png)  
I’m making a game like the classic Mario Party Bumper Balls - each player or AI agent controls a berry and tries to push the other ones off the plate.

 ![ai](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/a/2/ba2e26f0d718569aef8947c0fa130d168bd21b42.png)  
I have a simple Behavior Tree controlling the AI. First the berries select a target. Then, if they’re near the edge of the plate, they roll closer to the center. Once they’re away from the edge of the plate, they chase down their target.

_Some details: I’ve elected to use custom Behavior Tree Tasks to move the berries. I’m not using the NavMesh system - the AI just uses AddMovementInput, the same as the PlayerController._

In following the [Behavior Tree Quick Start Guide](https://docs.unrealengine.com/4.27/en-US/InteractiveExperiences/ArtificialIntelligence/BehaviorTrees/BehaviorTreeQuickStart/), I used the **Event Receive Execute AI** and **Finish Execute** nodes in my custom blueprint tasks. However, I noticed my AI opponents were rolling slower than my player controlled berry. I believe using those two nodes are slower than running code on the Tick event.

 ![BTT_AvoidEdge_Blueprint](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/2/e/12e351c1d1a241c04ece6597ac9dde979fdef66e.png)  
Following [the advice in this thread](https://forums.unrealengine.com/t/behavior-tree-only-ticks-every-other-frame/337222/9), I’ve swapped the event for **Receive Tick AI** and removed **Finish Execute.** This has fixed the slow AI issue.

However, now I’m not sure how to have the Behavior Tree correctly break out of the **BTT\_AvoidEdge** node, since I’m not calling **FinishExecute** anymore.

 ![BTD_CheckNearEdge](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/e/e/0ee43df85671dced1b59a815cf6eb094d06b1985.png)  
It would be logically clean if the **BTD\_CheckNearEdge** decorator could return fail once the berry was away from the edge. But when I add a print statement to its **Event Receive Tick AI** , it never runs. This makes me think decorators may only run initially - or at least as I have them set up.

What’s the best way to get the system to move on from the **BTT\_AvoidEdge** task once the berry is away from the edge of the plate?

---

<div class="post-metadata">

**Author:** ![JoeProgram](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/joeprogram/32/872486_2.png) [@JoeProgram](https://forums.unrealengine.com/u/JoeProgram)\
**Post date:** [April 27, 2023, 1:52pm UTC](https://forums.unrealengine.com/t/should-the-behavior-tree-task-or-decorator-break-out-of-a-task-that-runs-over-several-frames/1145272/2 "2023-04-27T13:52:12Z")

</div>

Figured it out.

Looking [at this post](https://www.reddit.com/r/unrealengine/comments/bi0xgv/help_with_decorators_not_running_each_event/) and [Mathew Wadstein’s video on decorators](https://youtu.be/kEI4Ez-WnJQ?t=261), I hadn’t set the “Observer aborts” setting.

 ![observer_aborts](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/7/a/07ac3a7580240a64f6a29e3725b81b2320b25966.png)  
Now the decorator will continue to run when its task, or any lower priority task, is run.
