AI Enemy Not Performing Task While Moving

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.

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.

1 Like

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 :sweat_smile:

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++.

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

I finally managed to fix the issue…and it was by accident :sweat_smile: 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!

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

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