x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Simple AI with Behavior Trees - Agro?

Hi everyone!

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

Product Version: Not Selected
Tags:
more ▼

asked Jan 11 '15 at 11:11 PM in Blueprint Scripting

avatar image

kallepewpew
5 2 4 4

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Hi Glacke,

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.

alt text

Thanks,

Peter L. Newton

more ▼

answered Jan 12 '15 at 02:02 AM

avatar image

PeterLNewton
2.1k 75 37 111

avatar image MieszkoZ STAFF Jan 12 '15 at 10:00 AM

I agree, I'd just use a Selector where Peter used Sequence, and make the Patrol a Sequence. The main reason for it being that with the original setup you'd end up with the whole sequence failing if "Found Enemy?" failed, unless you added a kind of "always succeed" decorator on top of it. Needless complication. Use this: alt text I'd also suggest making the "Found Enemy?" condition simple Blackboard-based check if your Enemy key is set or not (and you course you'll need to be writing your AI's enemy information into blackboard).

Cheers,

--mieszko

selector.png (97.0 kB)
avatar image kallepewpew Jan 12 '15 at 12:19 PM

Thank you both very much!

Just a quick question regarding the chart, what node should the found enemy/attack be? Same goes for patrol, is it a selector with a decorator or?

avatar image PeterLNewton May 12 '15 at 05:17 PM

Glackie -- were you able to figure everything out?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question