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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Parallel Execution in Behavior Tree

Hi guys

I am creating a simple behavior for a cannon.

The desired behavior is:

  1. Aim the cannon at the player, and simultaneously

  2. Fire and Reload on cool down.

I currently have the following Behavior Tree implemented: Current Behavior Tree

Predictably, this results in sequential execution of Aim, Fire and Reload. This causes rather 'jerky' behavior for the cannon since Reload task has a certain delay built into it.

How do I modify this to achieve the desired behavior? I want it to constantly run Aim task and Fire & Reload when these abilities come off cool down.

Thanks for your help

Product Version: UE 4.10
bt.png (33.0 kB)
more ▼

asked Dec 07 '15 at 11:09 AM in Blueprint Scripting

avatar image

Nick Jackson
492 17 14 107

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

3 answers: sort voted first

Ok - after spending 2 nights bashing my head on the wall. I finally worked it out. I tried Simple Parallel composite but I could not get it to work. For some reason it would always run the main task but it would never run the other tree. Here is the working Behavior Tree:

alt text

When I tried this before, it would only run Aim task and never run Fire and Reload. The reason for that behavior is very subtle. From the documentation: You can think of the Simple Parallel node as "While doing A, do B as well."

The reason why it did not work for me before is because I had Finish Execute node in the Aim Task. As a consequence, it would finish Aim when conditions were met and never execute the Fire and Reload sequence. Simple Parallel only works if the primary task does not finish.

This is not very obvious guys - could we please make it a little clearer in the documentation?

Thank you

more ▼

answered Dec 10 '15 at 12:10 PM

avatar image

Nick Jackson
492 17 14 107

avatar image SVR33 Apr 07 '16 at 07:01 PM

Thanks, for this, Nick! You saved me from pulling out what's left of my hair.

avatar image sonnyday_ Apr 14 '16 at 06:06 AM

I signed in to applaud you, Nick Jackson, as i was having this same problem and not much documentation on it!!

avatar image jblaswu May 23 '16 at 03:44 PM

thanks, this made the note "finish with main task" more clear...now it makes sense. i was using simple parallel and wondering why the branch was never executing. had Finish Execute on the task too.

avatar image luthage May 24 '16 at 01:34 PM

Have you tried making aim loop? Main task: sequence (with loop decorator) aim + maybe wait with a low time. Can make it loop indefinitely and if any other action is needed it can be forced out by an observer.

avatar image szundi Dec 29 '16 at 11:41 AM

Sir, thank you Sir! :)

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


I'm trying something similar.

I want to make an actor run around while shooting from time to time at a target.

alt text

However, as soon as I attach my Fire Task the main task isn't running anymore. It is running, though, if I add a Finish Execution node to the main task, but then the secondary task isn't executed anymore.

Are there any specific constraints on a secondary task? My Fire Task so far is just a "Print Hello"-Node and the option of a finish execution node (doesn't work no matter it's connected or not)

If I connect the finish execution node in my primary task, the primary is executed like intended, but my secondary task isn't executed anymore, as you have mentioned it.

Sorry, wanted to post as comment but I think, my image would vanish.

graph.png (105.3 kB)
more ▼

answered May 23 '16 at 08:50 AM

avatar image

96 6 10 17

avatar image E1andri1 May 23 '16 at 08:59 AM

okay, without the finish execute node, I assume, the primary task is executed only once, is that true? Do I need a while(true)-loop inside the task to keep it running?

avatar image E1andri1 May 23 '16 at 09:00 AM

turns out, you can't have a while(true) loop in a task as it throws an error.

avatar image luthage May 24 '16 at 01:41 PM

You can have a loop decorator though.

avatar image jblaswu May 23 '16 at 05:32 PM

Just started on AI days ago, so my approach might not be the best. I tested this tree. it will move to the Player Location and fire on sight, its a little more complicated than yours. Tell me if you run into any issue. Its important that you set the notify observer, that way it will work as a trigger and refresh the tree. If assume your waypoint picker is an roaming EQS, i would add that as a 2nd branch next to the simple parallel, so when it fails, the Pawn starts to roam around.

alt textalt textalt textalt textalt text

chasingfire.jpg (338.1 kB)
eqs.jpg (538.6 kB)
movetoplayer.jpg (592.8 kB)
firing.jpg (508.0 kB)
clearplayer.jpg (474.5 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Okay, I gained some new insights on this:

your main task can indeed execute the Finish Execution node, however your simple parallel node needs its execution flow mode set to "wait for sub tree"

If it's set so, then the execution of the tasks is pretty much straight forward and as one would expect.

more ▼

answered May 24 '16 at 10:11 PM

avatar image

96 6 10 17

avatar image jblaswu May 24 '16 at 10:48 PM

with Wait for sub Tree you mean Finish Mode to "Delayed"?

avatar image E1andri1 May 24 '16 at 10:56 PM

yes (strange, you have to write at least 10 chars to answer)

avatar image ddbrown30 Sep 30 '16 at 05:25 PM

The problem with this solution is that it has the opposite problem; once you finish the main task, it will never try to execute it again.

(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