Questions about my first behavior tree

_markL

New member
I tried to make a simple ai and here is the result

attack.png

Is this the correct way to design a behavior tree for a simple task like, if an enemy is in sight, chase it, then when it's in range attack it, otherwise, go wander? or is there a better approach? any suggestion will be great. thanks.
 
Looks good, the only thing I don't like here is using Repeater. My personal approach is to make tasks like Wander/Seek/Attack continuous actions which always return status "running". Because the conditions for these actions are checked outside of them (via conditional aborts). If you check conditions inside the action and return Success/Failure, then you add Repeater on top and restart the whole branch on each cycle. I used this approach at the beginning, but I don't like it anymore.

Just a simple example, to demonstrate the logic. The tree always stays in either Death, Attack, Get Item or Patrol state, or rather task. These tasks always run, they never return, so the behavior doesn't need to be restarted. Note that conditional aborts are set to "both" instead of "lower priority", so if enemy is no longer in sight, attack branch will cancel itself etc.

333.PNG
 
Last edited:
Top