Ai - UE4 - Enemy never moves after investigating noise

Hey guys. I’m very new to AI and I’m following a video series that’s a bit above my level of knowledge. I’ve set up the AI enemy to investigate a noise, but he never does anything else after getting to the noise location.

I’m really hoping you guys can tell me what I missed.

In the picture, the nodes I outlined, once fired, just keep flashing quickly over and over. There’s no node after the move to node. So should I have a wait node? Then what can I do to make it fi


re the nodes for either CautionSequence, or PatrolSequence?

I wish i knew enough to fix this but I hope someone has an answer.
Thanks guys

Hi, generally speaking:

In behavior trees nodes get executed from left to right. Then you have two things for execution flow: Selector and Sequence.
A Selector will execute its children from left to right until one of them succeeds, then the Selector will succeed upwards. If all its children fail, then the Selector will fail upwards.
A Sequence will execute its children from left to right until one of them fails, then the Sequence will fail upwards. If all its children succeed, then the Sequence will succeed upwards.

Then you also have decorators (e.g. BlackboardBasedCondition), specifying whether the task below can execute.


In your case, the execution flow will first go into the Selector on top. Then it will start executing its children from left to right, therefore starting with PatrolSequence. If the BlackboardBasedCondition decorator you have there will return false, then the execution will move over to InvestigationSequence (or if the decorator retunrs true but any of the children of PatrolSequence fail, then the Sequence will fail upwards and it will also execute InvestigationSequence next).

Overall, if PatrolSequence fails, it will execute InvestigationSequence next. Since it then gets stuck there, that means that both the BlackboardBasedCondition there keep returning true, and the MoveTo keeps running (or since you say that it keeps flashing that means the MoveTo succeeds very quickly, suggesting the target you want to move to there is already inside the acceptable radius).

Now, as long as InvestigationSequence succeeds, it will never go into AlertSequence.


For moving past the InvestigationSequence, you could make the InvestigationSequence fail after it ran once (e.g. make another decorator that returns false then), then it will go into the AlertSequence. If you want to go into CautionSequence from there, then you may need another decorator that prevents AlertSequence from executing.

And generally speaking, behavior trees are good at sequential behavior, but not really good for modelling transitions between ai states (like patrol, investigate, alert).

Oh okay. Could you tell me what decorator I should use to make it go into caution sequence after the move to in the investigation sequence, and which options to select? And this decorator would go on the investigation sequence, right?

I’m learning the basics here and there as well but I really want to get this to work now.

Thanks so much

So you know, the entire chain from the move to (under investigating sequence) up to the root flashes over and over. I’m really at a loss. I’ve tried a bunch of different decorators on that move to node but I get the same result every time. :frowning:

What you could do to get out of the InvestigationSequence after it ran once would be:

(-) create a new blackboard variable of type bool
(-) create a new task that sets a bool blackboard key
(-) in the InvestigationSequence replace the Selector by a Sequence
(-) add the new task after the MoveTo node, set the bool to false there
(-) add a decorator to the InvestigationSequence that checks the value of a bool, use your newly created bool variable there, check that the bool is true there

That above should make the InvestigationSequence only run once. Since I guess you will want to run it again once it gets something new to investigate, then there you will need to set the newly created bool variable to true again.


But if you’re following a video series, then maybe try to compare your code with that of the tutorial, or try to continue the tutorial a bit further to see if it works out later.

Hey, okay I don’t know how to do all that but it gives me a place to start. I do want it to be able to go back into investigation so I’ll keep that in mind.

Yeah he never shows his entire behavior tree,he only shows what he’s working on right now. I’ll go back in the series to try to piece it all together.

Thanks a ton for the help