# How to interrupt a Behavior Tree's processing?

**URL:** <https://forums.unrealengine.com/t/how-to-interrupt-a-behavior-trees-processing/2587691>\
**Category:** AI\
**Tags:** Behavior-Tree, unreal-engine, question\
**Created:** [July 2, 2025, 9:29am UTC](https://forums.unrealengine.com/t/how-to-interrupt-a-behavior-trees-processing/2587691 "2025-07-02T09:29:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Extrahdmi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Extrahdmi](https://forums.unrealengine.com/u/Extrahdmi)\
**Post date:** [July 2, 2025, 9:29am UTC](https://forums.unrealengine.com/t/how-to-interrupt-a-behavior-trees-processing/2587691/1 "2025-07-02T09:29:54Z")

</div>

Sorry for the beginner question.  
I’m trying to make a simple AI that will shoot when an enemy is in range and stop when it’s out of range. But the shooting doesn’t stop even if the enemy moves out of range.  
I tried decorators because I heard they work like branches, but changing the Boolean value doesn’t change anything.  
I attach a picture of the process.Can someone help me?

 ![Tree](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/0/0/e005d56cf34c1a92b25be5dec91a11234c62a85a.png)  
 ![Aim](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/4/e/14e6433d18e4fcc15b79be09dbb48fea87a5f20f.png)  
 ![Firing](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/b/d/2bdc17d3d569dd1bb4b453b5ef68b0c384ed0095.png)

---

<div class="post-metadata">

**Author:** ![SpecZynk](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/speczynk/32/1117840_2.png) [@SpecZynk](https://forums.unrealengine.com/u/SpecZynk)\
**Post date:** [July 2, 2025, 11:46am UTC](https://forums.unrealengine.com/t/how-to-interrupt-a-behavior-trees-processing/2587691/2 "2025-07-02T11:46:26Z")

</div>

Hi,

Hope you’re doing well.

Ok, we can handle that in a couple of ways.

The easeast way is make use of that blackboard decorator on the sequence node instead of your task none. So you will only aim and fire if your target is in range.

 ![Tree](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/6/c/76c5c6af1dda65c91fb569a50782ce4af91f6012.png)

So on your WeaponFire you can make use of the loop node, so you can have some shots in loop (e.g. 3 times) and the process will start over again.

By the way, where are you updating that variable `Is In Range`?

You can make use the [Behavior Tree Services Node](https://dev.epicgames.com/documentation/en-us/unreal-engine/unreal-engine-behavior-tree-node-reference-services)

Hope that helps - take care!

---

<div class="post-metadata">

**Author:** ![Extrahdmi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Extrahdmi](https://forums.unrealengine.com/u/Extrahdmi)\
**Post date:** [July 2, 2025, 5:00pm UTC](https://forums.unrealengine.com/t/how-to-interrupt-a-behavior-trees-processing/2587691/3 "2025-07-02T17:00:03Z")

</div>

Thanks for replying quickly!  
Yes, the variable that checks if the enemy is within range is InRange.  
Does the decorator’s place matter? The only one that requires a condition is WeaponFire, so I put it there. I don’t want AimTo to be blocked.

---

<div class="post-metadata">

**Author:** ![SpecZynk](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/speczynk/32/1117840_2.png) [@SpecZynk](https://forums.unrealengine.com/u/SpecZynk)\
**Post date:** [July 2, 2025, 8:57pm UTC](https://forums.unrealengine.com/t/how-to-interrupt-a-behavior-trees-processing/2587691/4 "2025-07-02T20:57:10Z")

</div>

Yeah,

It matters a lot.

Don’t worry, you are using a sequence node, which means all nodes inside it is going to ro run.

I got the idea, but I didn’t see any service node inside your behavior tree, so where are you updading that variable? How to you know if it true or false?

---

<div class="post-metadata">

**Author:** ![Extrahdmi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Extrahdmi](https://forums.unrealengine.com/u/Extrahdmi)\
**Post date:** [July 3, 2025, 4:45am UTC](https://forums.unrealengine.com/t/how-to-interrupt-a-behavior-trees-processing/2587691/5 "2025-07-03T04:45:41Z")

</div>

The value is set by SetValueAsBool in the AimTo task. Is this not working properly?

---

<div class="post-metadata">

**Author:** ![SpecZynk](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/speczynk/32/1117840_2.png) [@SpecZynk](https://forums.unrealengine.com/u/SpecZynk)\
**Post date:** [July 3, 2025, 12:08pm UTC](https://forums.unrealengine.com/t/how-to-interrupt-a-behavior-trees-processing/2587691/6 "2025-07-03T12:08:19Z")

</div>

It may work.

Look this reference node:  
[Behavior Tree Node Reference: Composites](https://dev.epicgames.com/documentation/en-us/unreal-engine/unreal-engine-behavior-tree-node-reference-composites)

But It will be updated only when AimTo task is running, in other hand, if you add that check to the `sequence`, it will update while the `sequence` is on.

By the way, did you make it work?

---

<div class="post-metadata">

**Author:** ![Extrahdmi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Extrahdmi](https://forums.unrealengine.com/u/Extrahdmi)\
**Post date:** [July 3, 2025, 2:22pm UTC](https://forums.unrealengine.com/t/how-to-interrupt-a-behavior-trees-processing/2587691/7 "2025-07-03T14:22:03Z")

</div>

It worked in the end.  
The problem was that when WeaponFire was executed, the AimTo task was finished, so the evaluation of InRanged was finished.  
When AimTo is run on Tick, it will continue to evaluate, allowing the tree flow to work.

I think it was a rookie mistake. But I learned a lot from your reply. Thank you for your help!
