Attack based on distance


New member
Hi everyone, I started using behavior designer a few days ago and I have no experience with behavior trees in general. In my own way, I managed to create something that worked, but I have a problem. With this behavior tree I am able to make an enemy chase and attack me when it intercepts me in a range of 7m, but I would like to let enemy to stay in attack pose when it sees me and start the attack only when it is find less than 3m (due to hand to hand attack), any help? I made some try already, i think the solution could be achieved using withing distance task, but i wasn't able to use it in the correct way. Many thanks.


  • Screenshot (191).png
    Screenshot (191).png
    153.8 KB · Views: 11


Staff member
Does it get the 7m from the Can See Object task at the bottom? For something like that using Within Distance is the correct route. As your tree continues to grow I recommend restructuring it and taking advantage of conditional aborts. This should make it a lot more straight forward to implement new functionality such as what you are going for. For a behavior tree that has this sort of functionality you can take a look at the character controller integration tree:

This explanation and structure is useful even without using any of our character controllers.


New member
I would say yes, all the other "can see object" tasks also work. As for conditional aborts, it is something that still does not enter my head, I cannot understand when to use it except just to switch between warden and seek.
Thanks for the link and for the answer, I will examine it thoroughly to understand what I could get from it.