Get AI to ADS and Shoot at the same time

Hey guys!

Im working on a small third person wave based shooter and ive almost finished, just working on small features.
Ive got the AI spawning in waves, moving towards the player and then shooting.

The AI character based off of the player character in terms of functionality, all in C++. Its got the same animation bp as well except for a few slight changes. Right now however the AI character is only using the rifle hip animations, i want him to (when in range) use the Aim Down Sight animation AND shoot the player at the same time.

This is my Behavior Tree right now, but for some reason the “Set Walk Speed” and “Aim At Player” arent triggered.

Any ideas on how i can go about fixing it?


Simple Parallel will only run the sequence while its main task hasn’t finished. What is likely happening is Shoot Player is finishing immediately, which causes the parallel tasks to get abandoned. There is a setting on the Simple Parallel to indicate that the sub tree needs to finish before continuing.

Instead, I’d recommend placing all of those nodes in a sequence:

  • Look At Player Sequence
  • Delay( 0.4 ± 0.1)
  • Sequence
  • Set Walk Speed
  • Aim At Player
  • Delay(0.1 ± 0.1) (Suggestion)
  • Shoot Player
  • Delay( 0.1 ± 0.1) (Suggestion)

That didnt seem to work, i tried both methods you mentioned, one with all the nodes in sequence and the other with delaying the Simple Parallel from finishing. Still nothing, not sure why though.

Are you watching the behavior tree when this is happening? Are you sure they’re all being fired.

If any of these tasks are returning failure, then you’ll need to force success with a decorator.

Make sure that the AI tasks do what they’re supposed to do when called manually.

I have watched, they literally just flash between each other and Shoot Player, So id assume theres something going wrong where they arent being triggered correctly?

I tried using Force Success but still the same issue - It seems to skip Set Walk Speed and Aim At Player and goes straight to the Shoot Player node

Ive got it working slightly, He aims and shoots at the same time, however the AI is shooting WHILE raising the gun to ADS… so id need to be able to switch it around so he aims first and THEN shoots.

That’s where the delay comes in.

You can also design your BTTasks to not finish execution until actually aiming at the player.

You can set breakpoints on the behavior tree to ensure things get hit.

This is what my BTTask AimAtPlayer looks like, any suggestions?

Got it to work with slightly modifying the Fire Function to include the Aiming Functions

Make Aim at Player only call Begin Aiming, and have a separate task for Stop Aiming. that way you can control the flow of aiming, shooting, and not aiming in the behavior tree.