# stuck at attack in behavior tree

**URL:** <https://forums.unrealengine.com/t/stuck-at-attack-in-behavior-tree/2691647>\
**Category:** Programming & Scripting\
**Tags:** Behavior-Tree, unreal-engine, question, Blueprint\
**Created:** [January 13, 2026, 12:06am UTC](https://forums.unrealengine.com/t/stuck-at-attack-in-behavior-tree/2691647 "2026-01-13T00:06:06Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Itsfate399](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Itsfate399](https://forums.unrealengine.com/u/Itsfate399)\
**Post date:** [January 13, 2026, 12:06am UTC](https://forums.unrealengine.com/t/stuck-at-attack-in-behavior-tree/2691647/1 "2026-01-13T00:06:06Z")

</div>

i have a behavior tree running for my horse, now i setup in the behavior tree to chase a target if target is set, and to attack it if in attack range, now i have an issue where the behavior tree is stuck at attacking the moment the target is set, even if its not in range it just stuck at attack when i changed the aborts to “both” for “TargetIsSet” and “DistanceToTarget”. i played with the aborts and sometimes the horse chases the target first, but when it reaches it, it starts attacking but stays stuck at it even if the target leaves the range. how to fix this issue, iam not that experienced in behavior trees.

**This is my behavior tree**

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/2/1/d21bdcccf158648602e5f9c25e0cc40272c34af8.png)

**This is the CheckDistance service**

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/6/8/968e2a5081bf45fa190536862d446becc5cae7ec.png)

**And this is the attack task**

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/5/f/a5f27dc90e05614e8d7a62581d07c12cf881ce84.png)

---

<div class="post-metadata">

**Author:** ![MajorT](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/majort/32/1219796_2.png) [@MajorT](https://forums.unrealengine.com/u/MajorT)\
**Post date:** [January 13, 2026, 12:18am UTC](https://forums.unrealengine.com/t/stuck-at-attack-in-behavior-tree/2691647/2 "2026-01-13T00:18:26Z")

</div>

Hey!  
Generally speaking you should always use the [GameplayDebugger](https://dev.epicgames.com/documentation/en-us/unreal-engine/using-the-gameplay-debugger-in-unreal-engine) to check the state of your AI and its BT Tasks.

Also just a hint to avoid weird issues like yours, in your `Event Receive Execute AI` function of your BT Task, make sure to also call `Finish Execute` when your cast node fails (but return Success = false)

Setting your blackboard conditions (TargetActor is set and Distance Check) to abort both itself and lower priority tasks is good as well.

For further help, could you verify if it actually is the BTTask\_HorseAttack that seems to be stuck?  
Also does it just execute over and over again or is it stuck in just one execution and never finishes (check what I said above) ?

---

<div class="post-metadata">

**Author:** ![Itsfate399](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Itsfate399](https://forums.unrealengine.com/u/Itsfate399)\
**Post date:** [January 13, 2026, 12:29am UTC](https://forums.unrealengine.com/t/stuck-at-attack-in-behavior-tree/2691647/3 "2026-01-13T00:29:28Z")

</div>

so what actually happens is it keeps executing over and over again in the behavior tree. and not the attack task itself, and incase i added the finishes execute = false for cast failed node. but still same issue, so its the behavior tree casting the attack none stop

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/5/9/a595b568923faeb46866e35b000432d8c748f261.png)

---

<div class="post-metadata">

**Author:** ![MajorT](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/majort/32/1219796_2.png) [@MajorT](https://forums.unrealengine.com/u/MajorT)\
**Post date:** [January 13, 2026, 12:33am UTC](https://forums.unrealengine.com/t/stuck-at-attack-in-behavior-tree/2691647/4 "2026-01-13T00:33:23Z")

</div>

Can you verify that the distance is correct and thus technically should make your distance check fail?

---

<div class="post-metadata">

**Author:** ![Itsfate399](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Itsfate399](https://forums.unrealengine.com/u/Itsfate399)\
**Post date:** [January 13, 2026, 12:35am UTC](https://forums.unrealengine.com/t/stuck-at-attack-in-behavior-tree/2691647/5 "2026-01-13T00:35:49Z")

</div>

okay so i checked the distance, and for some reason its always 0, it never changes

---

<div class="post-metadata">

**Author:** ![MajorT](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/majort/32/1219796_2.png) [@MajorT](https://forums.unrealengine.com/u/MajorT)\
**Post date:** [January 13, 2026, 12:40am UTC](https://forums.unrealengine.com/t/stuck-at-attack-in-behavior-tree/2691647/6 "2026-01-13T00:40:34Z")

</div>

And you did assign the proper TargetActor and DistanceToTarget Keys?

Note: Also you might want to use the inbuilt “distance” node instead of manually subtracting and getting the length of the result.

---

<div class="post-metadata">

**Author:** ![Itsfate399](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Itsfate399](https://forums.unrealengine.com/u/Itsfate399)\
**Post date:** [January 13, 2026, 12:42am UTC](https://forums.unrealengine.com/t/stuck-at-attack-in-behavior-tree/2691647/7 "2026-01-13T00:42:30Z")

</div>

okay so i fixed it, my problem was i wasnt actually assigning it in the behavior tree. i didnt set them to editable so i can change it. its crazy how i wasted 3 hours trying multiple stuff while the issue was simple XD. thank you for opening my eyes to look at simple stuff \<3

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/d/0/5d080675f1fb90d6730dbb70ed3f521d47078cfe.png)

---

<div class="post-metadata">

**Author:** ![Itsfate399](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Itsfate399](https://forums.unrealengine.com/u/Itsfate399)\
**Post date:** [January 13, 2026, 12:44am UTC](https://forums.unrealengine.com/t/stuck-at-attack-in-behavior-tree/2691647/8 "2026-01-13T00:44:29Z")

</div>

there is another thing bugging me, i have in the enemies a boolean for “is dead” but how do i actually make the horse see that the enemy “is dead” without having it to wait until the actor is destroyed.

---

<div class="post-metadata">

**Author:** ![MajorT](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/majort/32/1219796_2.png) [@MajorT](https://forums.unrealengine.com/u/MajorT)\
**Post date:** [January 13, 2026, 12:50am UTC](https://forums.unrealengine.com/t/stuck-at-attack-in-behavior-tree/2691647/9 "2026-01-13T00:50:38Z")

</div>

Well the way how you would implement something like this depends a lot on your skills in ue.

Usually what games would do is implement a custom sight affiliation filter that makes the enemy “visible” to the ai only under certain conditions (aka being alive, etc).

I assume (non-personal) that, since you said you’re pretty new to BTs, you would prefer a simpler solution 😀 .  
Also I would need to know more about how your AI logic is currently setup .

Either way, I would recommend you to check whether your enemy is alive every time your AI “sees” a new target and add another service in your BT that checks if the enemy is dead and then clears your TargetEnemy key.  
Its not ideal but by far the most simple way.

---

<div class="post-metadata">

**Author:** ![Itsfate399](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Itsfate399](https://forums.unrealengine.com/u/Itsfate399)\
**Post date:** [January 13, 2026, 12:53am UTC](https://forums.unrealengine.com/t/stuck-at-attack-in-behavior-tree/2691647/10 "2026-01-13T00:53:08Z")

</div>

understood, i will be trying that. Thank you!

---

<div class="post-metadata">

**Author:** ![MajorT](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/majort/32/1219796_2.png) [@MajorT](https://forums.unrealengine.com/u/MajorT)\
**Post date:** [January 13, 2026, 12:55am UTC](https://forums.unrealengine.com/t/stuck-at-attack-in-behavior-tree/2691647/11 "2026-01-13T00:55:47Z")

</div>

You’re welcome!

(for my forum stats, would you actually mind marking my comment (instead of yours) as the solution?  
That would help me a lot getting a better rating 😄 )

---

<div class="post-metadata">

**Author:** ![Itsfate399](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Itsfate399](https://forums.unrealengine.com/u/Itsfate399)\
**Post date:** [January 13, 2026, 12:58am UTC](https://forums.unrealengine.com/t/stuck-at-attack-in-behavior-tree/2691647/12 "2026-01-13T00:58:19Z")

</div>

no worries

---

<div class="post-metadata">

**Author:** ![MajorT](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/majort/32/1219796_2.png) [@MajorT](https://forums.unrealengine.com/u/MajorT)\
**Post date:** [January 13, 2026, 12:58am UTC](https://forums.unrealengine.com/t/stuck-at-attack-in-behavior-tree/2691647/13 "2026-01-13T00:58:56Z")

</div>

thank you, I appreciate it! 😄
