Behavior Tree Task Issue

Hi all, I’ve run into trouble with a certain Behavior Tree task. I have in my level three or four actors which represent bases. I want the AI pawn to locate the nearest one and move to it. after waiting a little while he will proceed to the next nearest one and so on.

I am fairly sure this can be done with a BT but don’t know how to achieve it. The main Idea is to have a task where he locates the nearest base then another where he proceeds to it.

Thanks.

Hello Van2015,

A good way to accomplish this would be to use EQS. In order to enable EQS in your project, go to Edit->Editor Preferences->Experimental and then check the Environment Querying System box. Then, you can create an EQS by right clicking in the content browser and selecting it from under the AI section. Once you do this, you can drag off of the Root and add ActorsofClass. This will find all of the actors of whatever class you specify within whatever range you set.

Then in your BT, you can set up a sequence that Runs your EQS query and moves to the target object. You’ll also need to ensure that you have a key in your blackboard to store the target object. You’ll need to mess around with the settings to get it to do exactly what you’re trying to do, but this should at least get you a good start. Let me know if you need further explanation.

Hi Sean Flint.

I’ve managed to get the EQS to generate however I can’t replicate what you have coming off the EQS root. Could it be possible to show the detail panel of each of the tasks and what setting you have to get the “between 1000 and 5000” and the “up to 3000”?

I have the BT running the EQS but haven’t been able to set the target object properly.

The reason you can’t set the target object is most likely because the distances that I set in my project are not far enough to detect the bases that you are looking for. Try setting the radius of the ActorsofClass to a large number in order to increase the search radius. This radius determines how far it will look to populate the list of actors. Give that a shot and let me know if you have any more questions or need clarification.

Here are the details panels. The first is the Actors of Class, second is the Path Length, and third is the Distance To.

62653-actorsofclassdetails.png

I appear to be getting results but the AI pawn still doesn’t move towards the base I will attach some images and possibly you will be able to see the error.

I have set very large numbers on the EQS distance to make sure he finds the bases.

Here are the strings I get on the locations when previewing.

thanks a lot for being patient with me. I’m new to AI and EQS. :slight_smile:

In your blackboard, instead of setting the base class to your BaseStation class, try setting it to Actor or whatever your BaseStation class is based on. Also, when you run your game, look at your behavior tree and see what the value for Base is set to, just to make sure that it is being set properly. Give those things a try and let me know how it works out.

I did as you said and ran some debugs. For some reason it’s not even setting the base. Should I set the base station as blackboard object somewhere in blueprint and also run the EQS in the controller instead of just in the BT?

Debug images

Actually, try setting your Path Length and Distance to 0 as the minimum length instead of 90000. This would mean that if the object isn’t at least 90000 units away, it will not populate the key. It should read “Between 0 and 100000” instead of “Between 90000 and 1000000.” Give that a shot and let me know how it works.

It’s coming along! Now the EQS and Blackboard are setting the Base Stations as the target object, however the pawn still doesn’t move towards them.
Do I need to create a custom task?

  • Do you have your behavior tree set to run in your AI Controller?
  • Is your AI Character set to use the AI Controller you created?

If those are both set, it would be helpful if you could zip up your project and upload it to google drive or dropbox and provide me with a link so I could take a look at it and see exactly what is preventing this from working properly.

Yes the Controller runs the Behavior Tree and the character uses the controller.

Sounds good. I should have something for you tomorrow. It will be a dropbox link.

Thanks for all your help!

Whoops! Just found the issue. In my Behavior Tree the “run EQS” and “move to” nodes branch from a “Selector” instead of a “Sequence”. Now it all works fine. I think I can play with it now.

Just one more question because I think you would know. Regarding AI is there any tutorial that shows me how to achieve something like this for Enemy Shooter AI. I know he didn’t use Behavior Trees though.

Fantastic, I’m glad that you were able to solve the issue. I completely missed that Selector myself.

In terms of AI tutorials at this point, a lot of the official ones are outdated. The best way to figure it out is to have a clear idea of what you’d like to accomplish and then just try to make it work. From what I saw in the video and the comments, it seems that he is using the pawn sensing component to achieve his results. The documentation on this is very light, but you might be able to find a tutorial online somewhere that will help get you started. Here is the AI Components documentation: AI Components | Unreal Engine Documentation
Good luck!

Thank you so much for your time and answers! I better do some reading lol.