# AI Enemy Not Performing Task While Moving

**URL:** <https://forums.unrealengine.com/t/ai-enemy-not-performing-task-while-moving/1790892>\
**Category:** AI\
**Tags:** UE-5, Behavior-Tree, behavior-tree-task, unreal-engine, question\
**Created:** [April 6, 2024, 1:59pm UTC](https://forums.unrealengine.com/t/ai-enemy-not-performing-task-while-moving/1790892 "2024-04-06T13:59:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![GV-Rafael-III](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GV-Rafael-III](https://forums.unrealengine.com/u/GV-Rafael-III)\
**Post date:** [April 6, 2024, 1:59pm UTC](https://forums.unrealengine.com/t/ai-enemy-not-performing-task-while-moving/1790892/1 "2024-04-06T13:59:05Z")

</div>

I am trying to get my AI-controlled enemies to shoot or reload while moving towards the player. The “Shoot” and “Reload” tasks just play the corresponding animation montage, and return _EBTNodeResult::Succeeded_. Unfortunately, enemies shoot while moving just fine but cannot seem to reload until they reach their destination first.

I don’t see anything in the tasks themselves, or the enemy class, that would cause this to happen. The animations I am using are from a Marketplace pack, but I have used them before on the player in a different project, and the reload animation worked just fine while moving. I’m not aware of anything in the animation assets that would make things more difficult for AI-controlled actors, either.

I’m assuming that the issue lies somewhere in my behavior tree, but so far I haven’t been able to figure out what’s going on. Is anyone able to help? This is on UE 5.2.1.

 ![behaviortree](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/a/b/6ab3d1681d82d3074207ab0ea70e80bd4648d402.png)

---

<div class="post-metadata">

**Author:** ![illspiritx](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@illspiritx](https://forums.unrealengine.com/u/illspiritx)\
**Post date:** [April 7, 2024, 7:58pm UTC](https://forums.unrealengine.com/t/ai-enemy-not-performing-task-while-moving/1790892/2 "2024-04-07T19:58:06Z")

</div>

To get ai to reload while moving, you could either use a Simple Parallel node and have reload as the the task, or put the reload stuff in a service running inside a selector or sequence node.

---

<div class="post-metadata">

**Author:** ![GV-Rafael-III](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GV-Rafael-III](https://forums.unrealengine.com/u/GV-Rafael-III)\
**Post date:** [April 8, 2024, 1:41am UTC](https://forums.unrealengine.com/t/ai-enemy-not-performing-task-while-moving/1790892/3 "2024-04-08T01:41:03Z")

</div>

Thanks, I’d been thinking about it over the past day and will likely go the service route. They run parallel in a way that’s easier for me to understand and I’m out of ideas so why not 😅

---

<div class="post-metadata">

**Author:** ![GV-Rafael-III](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GV-Rafael-III](https://forums.unrealengine.com/u/GV-Rafael-III)\
**Post date:** [April 8, 2024, 2:16pm UTC](https://forums.unrealengine.com/t/ai-enemy-not-performing-task-while-moving/1790892/4 "2024-04-08T14:16:45Z")

</div>

Unfortunately, turning reloading into a service didn’t help. Enemies still have to stop before they can do it. In addition, I tried turning shooting into a service out of curiosity and now the shooting doesn’t work properly, either. Enemies will shoot several times instantaneously, and only do so once, then reload right after.

The logic in my services is being executed by Receive Activation AI, similar to how the logic in my tasks was being executed by ExecuteTask() in C++.

 ![behaviortree_2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/6/a/a6af436a00202e69eb3e68e8fc3fa3219f4dc3b0.png)

Clearly I don’t understand services as well as I thought…

---

<div class="post-metadata">

**Author:** ![GV-Rafael-III](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GV-Rafael-III](https://forums.unrealengine.com/u/GV-Rafael-III)\
**Post date:** [April 8, 2024, 5:54pm UTC](https://forums.unrealengine.com/t/ai-enemy-not-performing-task-while-moving/1790892/5 "2024-04-08T17:54:16Z")

</div>

I finally managed to fix the issue…_and_ it was by accident 😅 When looking at my behavior tree (in the OP), I realized that I don’t really need two Simple Parallel nodes. So I put both my shooting and reloading tasks under a Selector node for the same Simple Parallel, and suddenly the enemies can reload while moving!

 ![behaviortree_3](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/4/b/74b665c1e7c12f4f6fa8a97389dbcbbef5d9597c.png)

As stressful as this ordeal has been, I’m very glad to see it come to an end.

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [May 8, 2024, 5:54pm UTC](https://forums.unrealengine.com/t/ai-enemy-not-performing-task-while-moving/1790892/6 "2024-05-08T17:54:33Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
