# Is there way to skip a behavior tree task after it is called once?

**URL:** <https://forums.unrealengine.com/t/is-there-way-to-skip-a-behavior-tree-task-after-it-is-called-once/480672>\
**Category:** AI\
**Tags:** Behavior-Tree, task, unreal-engine, question\
**Created:** [March 22, 2021, 2:48am UTC](https://forums.unrealengine.com/t/is-there-way-to-skip-a-behavior-tree-task-after-it-is-called-once/480672 "2021-03-22T02:48:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![DavidTveraas](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/davidtveraas/32/1058281_2.png) [@DavidTveraas](https://forums.unrealengine.com/u/DavidTveraas)\
**Post date:** [March 22, 2021, 2:48am UTC](https://forums.unrealengine.com/t/is-there-way-to-skip-a-behavior-tree-task-after-it-is-called-once/480672/1 "2021-03-22T02:48:42Z")

</div>

I used a behavior tree to create a dialog system in my game. It works very well except I can’t seem to find a way to get the characters to stop repeating their opening dialog once the first Selector’s Child has succeeded. Once any of the dialog branches I highlighted in green finish, it runs the opening exchange (in red) again. Is there a decorator I could use that allows for a “Do Once” type of action where the NPC would stop re-greeting them before giving dialog choices, or is there a better way to structure my behavior tree where the options are presented at a higher priority than the NPCs greeting?

 ![333175-speaking.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/2/f/c2fc7acb61f5e08aff836724328bd4f1f484007b.png)

---

<div class="post-metadata">

**Author:** ![Kehel18](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Kehel18](https://forums.unrealengine.com/u/Kehel18)\
**Post date:** [March 22, 2021, 4:01pm UTC](https://forums.unrealengine.com/t/is-there-way-to-skip-a-behavior-tree-task-after-it-is-called-once/480672/2 "2021-03-22T16:01:10Z")

</div>

Hello! I think the simplest solution - to add special context variable in your Blackboard. This variable will keep for example tree level (you just need to identify dialog nodes into logical groups). After that let tasks that dont correspond to current value of this variable will return Succeed at once and Sequence can go into further execution… And dont forget - you need to change this variable somewhere in tasks

---

<div class="post-metadata">

**Author:** ![DavidTveraas](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/davidtveraas/32/1058281_2.png) [@DavidTveraas](https://forums.unrealengine.com/u/DavidTveraas)\
**Post date:** [March 25, 2021, 4:38am UTC](https://forums.unrealengine.com/t/is-there-way-to-skip-a-behavior-tree-task-after-it-is-called-once/480672/3 "2021-03-25T04:38:56Z")

</div>

How would I add a special context variable? Would it be setting a counter via a custom decorator? I’ll experiment with that, but I’m open to suggestions.

---

<div class="post-metadata">

**Author:** ![Kehel18](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Kehel18](https://forums.unrealengine.com/u/Kehel18)\
**Post date:** [March 25, 2021, 6:04am UTC](https://forums.unrealengine.com/t/is-there-way-to-skip-a-behavior-tree-task-after-it-is-called-once/480672/4 "2021-03-25T06:04:33Z")

</div>

You can simply set BB value to value of current task node after it is executed. And check for \< when starting executing task nodes. So, at first execution task node will execute fully because **BB value** \< **self node value** and then set **BB value** to **self node value**. At second execution **BB value** \< **self node value** is false, so task node simply return Succeed
