Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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. alt text

Any ideas on how i can go about fixing it?


Product Version: UE 4.21
untitled.png (98.9 kB)
more ▼

asked Apr 09 '19 at 01:11 PM in Blueprint Scripting

avatar image

1 1 2 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

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

more ▼

answered Apr 23 '19 at 02:47 PM

avatar image

1 1 2 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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)

more ▼

answered Apr 09 '19 at 03:55 PM

avatar image

2.2k 39 17 52

avatar image KingSpud Apr 09 '19 at 04:28 PM

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.

avatar image BenVlodgi Apr 10 '19 at 02:12 PM

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.

avatar image KingSpud Apr 10 '19 at 03:00 PM

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

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

avatar image BenVlodgi Apr 10 '19 at 10:22 PM

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.

avatar image KingSpud Apr 10 '19 at 10:54 PM

alt text

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

untitled.png (82.9 kB)
avatar image BenVlodgi Apr 23 '19 at 04:17 PM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question