Prevent task restart when a parallel task is finished

arenoo

Member
I think this should be a fairly simple thing to do but I can't get it working. I am using the deathmatch ai kit default behavior tree. I want to add a branch that will wait 5 seconds and start ability (in my case I added a custom jetpack ability). I added a parallel node on top of the main logic branch and I thought that would be the solution, however It caused throttling of the main branch because it had a 5 second timer in it and the main branch was forced to wait for that timer. Then I made it a Parallel Complete node to fix that, but now when the main execution branch finishes execution (for example when I shoot the agent and the damaged) it causes the jetpack branch timer to restart (which I know is expected). How do I prevent it from restarting and don't interfere the execution of the main branch logic? i.e. don't make the main branch wait until the jetpack branch finishes. I want them to be completely separate from each other.
1692019156629.png
 
You are using parallel complete which will stop the execution of other children as soon as it is complete. You should use a regular parallel task, and place it above the repeater so the repeater can repeat the other branch.
 
This works but I guess this is a better way to phrase my question:
Lets say branches A and B are connected to the same parallel node parent. Branch A has a greater priority and has the abort type set to lower priority (you can imagine it like Attacked branch). Branch B has some logic that repeats forever (like patrol branch). Now lets say the B branch was in the middle of execution and the agent got shot. Brach A aborts branch B and does it's logic. After that the branch B is restarted even though it was not all the way done when branch A stopped it. How do I make branch B continue from where it was aborted? btw Im not 100% sure that I wrote this all correctly but that is how I understand this system now. Also I think it would be better if I included the exact problem that Im facing so here it is. Again, Im using default behavior tree that came with Deathmatch AI kit. I want to make the agent crouch when it spots the target and starts shooting at it. I have a sequence that goes like this: as soon as it sees the target it waits 0.5 seconds -> crouches -> waits for 3 seconds -> stops the crouch ability. If I shoot the target when it is crouched and is waiting for the second timer to stand up the branch gets reset and the agent never stands up again. How do I make it not abort the crouching branch and still have it execute the Attacked branch at the correct time?1692093883472.png
 
Last edited:
With the parallel task there isn't a concept of priority since they are all run during the same tick. The parallel task also doesn't respect conditional aborts since that logic doesn't make sense with the parallel task. The child tasks are always executed so conditional aborts wouldn't help at all since all they do is execute a task every frame. I notice that you have a conditional abort on a parallel task and that'll result in unknown behavior.

You cannot restart a task from where it was previously executing. Behavior trees by definition have implicit transitions between tasks and unlike a finite state machine you cannot set a direct transition. The only way for a tree to be executing a task is because the conditions allow it.

One way to handle your crouch use case is to use the Interrupt/Perform Interruption tasks. This will allow you to explicitly interrupt a branch when the perform task runs.
 
Top