Download

Blueprint Ai or Behavior Trees?

I posted this in content creation, but it may be better suited for here.

I have just started in UE4 and i am really enjoying it. While watching Youtube videos and such on AI, my favorite so far has been VirtusEdu, but he does Ai in the actual blueprints via Move-to nodes and other things, but i was wondering if AI is best handled with Behavior trees. I have never worked with them and continuing to use just nodes in the blueprints to dictate Ai movement and behavior is going to get clustered fast.

I’ve gone back and forth on this quite a bit.

First, I used blueprints. I used the perception system to have the AI follow a detected player. After doing some research, I learned about the behavior trees and decided to give them a shot.

So, my first venture into behavior trees … did not go well. I didn’t understand decorators very well and it seemed more suited for simple behavior than the complex behavior I was attempting to create. So I went back to blueprints.

I created a massive blueprint to handle all sorts of scenarios. What to do if the AI is idle, how to handle seeing the player, hearing the player, whether it should run from multiple players, EQS queries to handle movement paths and I used “Add Movement” nodes to move the AI instead of “Move-To” so that I could smoothly update targets and the rotation wouldn’t look weird. It worked great … in single player. In multiplayer, the process was not smooth. I needed everything to execute on the server and the number of branches I used, checking perception and ensuring the path was valid along with using the “Add Movement” made for a very jittery/janky experience. So I took another look at behavior trees.

Turns out, you can configure these trees much better than what I had first thought. And using services seems to handle repeated calculations much better than navigating through a blueprint on every tick. They appear to have done some pretty nice optimizations on how those are processed. It did take a bit of work to get it to do the same thing my blueprint did with some wonky bits in there to handle odd situations (like re-starting a composite node to re-calculate a path before re-executing a “move to”) but so far so good. And it runs much smoother. And it looks much cleaner than my event graph.

I’d say behavior trees are definitely worth using.

I’m Behavior Trees all day when it comes to complicated AI. If you need a simple AI moving from A to B, you can use blueprint AI.

OK cool, I am still in the beginning stages of learning UE4 AI, so its not TOO complex, but within the blueprints, i have the AI pawn sensing moving to the player and executing a “kick” along with a damage component that just subtracts the health variable whenever either the “on overlap” happens or the AI stays within the players overlap for a certain time. It is garbage coding and i really need to learn better AI because a lot of things don’t work right now such as the “ApplyRadialDamageWithfalloff” can’t get that to work at all, but thats another post for a later time. I will check out Behavior trees, thanks guys!