How to run a branch in parallel with a running task?

bazzboyy1

New member
Hello,

I'm trying to have my AI constantly try to find the closest target while it's moving towards its existing target. When the AI is attacking however, I want it to stay on the existing target. How can I achieve this?

Bottom left branch is the targetfinding branch, then in parallel im trying to run MoveToTarget but the branch only runs once (since MoveToTarget removes running)

This is what I have so far...


Capture.PNG
 
Last edited:
Also having running tasks also prevent the top branch tasks from running which I need for updating data (GetDeltaTime, Increment Attack Time).

Am I doing this wrong?
 
Mmkay so I managed to solve some issues by doing using the repeater task as a parent for my tasks that need to run every frame,
I also added a conditional task CurrentTargetIsClosest and set my parent sequence to use a self conditional abort.

This however introduces an optimisation issue, the GetClosestEnemyTarget action makes the same calculation as the CurrentTargetIsClosest condition which is a bit intensive (sphercasting). Is there anything I can do to fix this issue?

Capture.PNG
 
This however introduces an optimisation issue, the GetClosestEnemyTarget action makes the same calculation as the CurrentTargetIsClosest condition which is a bit intensive (sphercasting). Is there anything I can do to fix this issue?
One Spherecast isn't bad at all and can easily be run every frame. Just make sure you are using the NonAlloc version of the spherecast. Your tree looks like it has a similar setup as the tree that we created for our character controller - even if you don't have the character controller this is an extremely useful resource:

 
One Spherecast isn't bad at all and can easily be run every frame. Just make sure you are using the NonAlloc version of the spherecast. Your tree looks like it has a similar setup as the tree that we created for our character controller - even if you don't have the character controller this is an extremely useful resource:


Wow I didn't know you had such a detailed tree for reference! Fantastic. I thought behaviour trees would have been more intuitive but it's been a bit of a learning curve for me. Good to see I'm on the right track.

It would be nice if there was some way to run an action before a conditional task while using conditional abort (since my action updates a sharedvar that the conditional depend on)!

Cheers
 
Yeah, behavior trees take a bit to get used to but once you get the hang of their flow you'll wonder how you designed AI without them in the past.

There isn't a way to have the action task run along the side of the conditional task but in that case I think having the conditional task update what the action task would update makes sense.
 
Top