AI not behaving like expected...

Hello everyone, I’ve been trying to make a AI that will follow a simple rule.
If the controlling pawn’s football team has the ball It will attack, if not it will go back and hold position.
I tried using the Nav Mesh Areas Component and the Nav Filter Query to tell the AI what areas it can go (editing the travel cost overrides), but so far I haven’t managed to make it work.
Does anyone know a better solution, or a way to solve the Problem?

Viewport:

Example of the Nav Area Blueprint:

Nav Query Filter Example:

Hey @M411!

This actually seems more like a problem with the Behavior Tree or AIController. Would you mind sharing relevant parts of those blueprints for us? :slight_smile:

1 Like

Sure, the behaviour tree is real simple because I 0m still learning the AI basics but here it is:

Get Rand Postion Task:

Change Filter Status Task:

Ah, there’s your problem! In the Behavior Tree, your Decorator is a bool that says

“If team does not have ball, do all three of these.
If team does have ball, do none, start over.”

So you have several logic loops there. Is Not Set=False, Is Set = True.The team without the ball will choose a random location and go there. The team WITH the ball will stop and never move again.

Also, to clear up some possible misconceptions about the modifier zones: your zones don’t change the likelihood of there being a random spot chosen within them, the zones are about pathing to the chosen destination. If they choose a spot in the “hardest” location, they’re going, they’re just going to choose the path with the lowest cost, not the destination with the lowest cost. And higher cost locations are just as likely as the lowest cost to be chosen.

You need 2 branches here where you have 1: so you need to make a branch that is “IS set” for teamHasBall, and then above your two branches have a selector with a Service that checks the status of teamHasBall to determine which branch to run

To give them certain places to go, I’d suggest creating points on the map for them to choose from and go to, with a 300-400 acceptable radius. So say, if have ball, go to spot D,E,F, or G within 3 meters, then next action.

I hope this helped! :slight_smile:

1 Like