Simple AI with Behavior Trees - Agro?
So im struggling a bit to make AI, and my struggle is within the Behavior Tree. Im managing to get the AI to follow the player or patrol around the navmesh - basically i'm able to get the AI to execute simple tasks. However, what I want to do is to make the enemies patrol and when the player is within a certain agro range, the AI should follow the player.
How would one manage the behavior tree in this cituation? I've tried all the tutorials I could find but I can't get it to work. I should mention that i'm doing it in the third person example project.
TL;DR - How would I structure the behavior tree when I want AI to patrol around and then execute another task when the player is within a certain range.
Thanks for reading! Best regards, Glacke
asked Jan 11 '15 at 11:11 PM in Blueprint Scripting
To make this as simple as possible! What I suggest is a sequence node immediately after your Root node. This will allow you to control you execution, and prevent another node from being executed before the previous one finishes.
So in our case we create the first node Attack! which has a Decorator Found Enemy? . This node only executes if an enemy is found. Once an enemy is found, the node shouldn't finish execution until the enemy is lost. I suggest putting this logic on the Pawn itself. So the enemy check is done by the Pawn, so the Decorator gets that information from the Pawn. Once the enemy is found, the Attack! node assigns a Event Dispatcher which is for your Enemy Lost Event on the Pawn itself. Once the enemy is lost, Pawn calls Enemy Lost. The node Attack! with the Enemy Lost Event Dispatcher Assigned is called finishing execution.
The next node is straight forward, this state gets the next route and moves towards it. Main node should be sequence to allow proper flow execution. Current route information should be stored in the Blackboard Asset.
So the idea is, should I be attacking now? No, keep patrolling. Usually this is the approach for FPS. Shoot or Don't Shoot is the question.
Peter L. Newton
Follow this question
Once you sign in you will be able to subscribe for any updates here