How to Build a behavior tree which triggers by a condition and run an "Action chain" properly?

LoneliNerd

New member
Hi, New to Behavior Designer here, I'm trying to build an "action chain" which will be triggered when some condition is fulfilled. To be specific, what I want to finish is an enemy AI within the steps below.

1. Check if the player inside its detect range
2. if it isn't, do nothing; if it is, rotate to and look at the player direction
3. when the angle between player and enemy is less than some degree, the enemy stops rotating.
4. move backward a little bit like some kind of "warm-up action"
5. rush straight forward.


After making clear of these steps, I tried to build my behavior tree like the picture below.

  1. Check if the player is inside its detect range => If it is, rotate to and look at the player direction until the angle difference is less than a threshold
    • Step1-2.png
  2. Move backward and rush forward for specific seconds respectively
    • Step3-4.png

Every single action logic is fine and works properly, but when I try to build a link between them, a problem appeared. When the player was detected, the enemy will rotate to and finally look at the player's direction, so far is fine. But after that, the enemy will move backward, this action will cause "Player Leave the Detect Range", and once the player leaves the enemy's detect range, the enemy's action will stop, and it confused me, how should I build an "Action chain" which won't break after some condition is fulfill, and the condition will restart checking after the whole "Action chain" is finished.

If there are some better behavior tree building logic advice or some behavior block I should use, please tell me, any help will be appreciated! thanks!
 
I would need to play it in order to really see it in action, but if you want to reevaluate a conditional task every tick I recommend using conditional aborts instead of the repeater. This should streamline your tree a bit more and will probably also help you get the functionality that you're going for. This page has a video and description on conditional aborts:

 
I would need to play it in order to really see it in action, but if you want to reevaluate a conditional task every tick I recommend using conditional aborts instead of the repeater. This should streamline your tree a bit more and will probably also help you get the functionality that you're going for. This page has a video and description on conditional aborts:


I have added a bool variable and tried to control the flow, and replaced repeat with condition aborts that you told me, but it seems still very weird. Maybe you can take a look? The unity package is attached.
 
Please do not upload packages that contain Behavior Designer as not every one on this forum has a license to it.

With that said, when I played the scene and moved the player towards the shark the shark didn't move at all. I haven't studied your actions but you have a lot of conditional aborts setup where there are no conditionals. For example, on your rightmost branch, you have a lower priority abort setup on every sequence task but there are no branches to the right of those branches so the abort will never trigger. Also, conditional aborts only operate on conditional tasks and do not recognize action tasks.

Here's a more complete tree that has the design I think you should go for. This is using our character controller but the video explains what is happening really well so you can study it without needing the integration:

 
Please do not upload packages that contain Behavior Designer as not every one on this forum has a license to it.

With that said, when I played the scene and moved the player towards the shark the shark didn't move at all. I haven't studied your actions but you have a lot of conditional aborts setup where there are no conditionals. For example, on your rightmost branch, you have a lower priority abort setup on every sequence task but there are no branches to the right of those branches so the abort will never trigger. Also, conditional aborts only operate on conditional tasks and do not recognize action tasks.

Here's a more complete tree that has the design I think you should go for. This is using our character controller but the video explains what is happening really well so you can study it without needing the integration:

Sorry for the package uploading mistake, going to study this case, thanks a lot!
 
Top