0
\$\begingroup\$

I am new to UE4 and game programming altogether. Following multiple tutorials and documentations I see mentions of behavior trees. In tutorials they do not use them in favor of blueprints because they do not want to complicate it.

I can find many resources about behavior trees with "HOW" but I can not find any "WHY". So my question is, why does it exist and why should I learn it, or if I even should? What are advantages of it comparing to blueprints or even writing my own code?

\$\endgroup\$
2
  • 2
    \$\begingroup\$ Presumably you started by searching for "advantages of behaviour trees"? This turns up quite a few articles that outline the strengths of this approach in comparison with other common AI techniques. Was anything you found in that search unclear, or are there specific points the resources you've researched don't address? \$\endgroup\$
    – DMGregory
    Oct 16, 2020 at 15:10
  • \$\begingroup\$ I was searching, but not this exactly. Search you provided pointed me to interesting reddit thread where I;ve found answer. "...it's biggest benefit is that it's a tool designed around creating AI specifically. It makes you structure your logic in a way that is visually easier to troubleshoot in simulation as your AI gets more complicated.. but logically I don't think it does anything magical that couldn't be done without it..." And "Most of the non-blackboard AI functions are really buggy anyways, and I was only able to get error tolerant AI using the behavior tree..." \$\endgroup\$
    – psznm
    Oct 16, 2020 at 15:23

2 Answers 2

0
\$\begingroup\$

Personally from going from a finite state machine to a behavior tree i find there are multiple advantages:

  1. Iteration time: With a behavior tree you have modules that are kind of like Lego-blocks, so you can put together a couple of behaviors and you can have an AI up and running rather quickly. Say you want it to chase the player. You create a sequence called "Chase Player", you make it rotate towards the player, you set the speed and then finally you tell it to move, and then it will repeat those steps untill either its out of range or any other condition you set for "Chase Player"
  2. Modularity: As said above, you have several nodes which are the building blocks of the AI. Those are different parts that come together to create a functioning AI. And its only your imagination that will limit what the AI can do. And you can define the parameters yourself, say in "Chase player" the speed node needs to be 10, but in "Flee" the speed node needs to be 20. It's all decoupled from eachother as you create individual nodes, which makes it flexible.
  3. Tree-like structure The behavior tree is a tree as the name suggests, which means each composite node, or a root node / a sub root node, (ie Chase player) have branches that have their own nodes, or leaves if you want to call it that. Meaning each composite node controls their own branches and nodes attached. Again, this allows for modular and decoupled design. Meaning you can have 1 composite node have 10 branches for one behavior, while another composite node may have 2 or 5, it's all up to you to decide how complex a behavior should be.

So yea, i would suggest learning Behavior Trees for those simple reasons, it might have a steep learning curve as there are a lot of concepts to wrap your head around in the start, but once you get familiar with it, prototyping AI becomes really easy. And also it has been around since the Halo days, and it's still widely used in games, so if you need reference, hit up some games and study their behavior. Happy dev'ing.

\$\endgroup\$
0
\$\begingroup\$

Taken from a reddit thread: "Most of the non-blackboard AI functions are really buggy anyways, and I was only able to get error tolerant AI using the behavior tree."

  • this indicates that if using Behavior trees, it is harder to make bad errors in your AI

Taken from a reddit thread: "In my (admittedly very limited) experience, it's biggest benefit is that it's a tool designed around creating AI specifically. It makes you structure your logic in a way that is visually easier to troubleshoot in simulation as your AI gets more complicated.. but logically I don't think it does anything magical that couldn't be done without it."

  • this also indicates the same and also that the more complex your AI, the more Behavior trees shine.

https://www.reddit.com/r/unrealengine/comments/6t1ca0/advantages_of_using_behavior_tree_so_far_its_more/

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .