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"

AI Problem

Good day everyone! I have a question regarding AI in Unreal Engine, I'm using behavior tree. I want that every time one of the enemy hears my character they will come to it.

What settings do I need to do with my Blueprint or Behavior Tree.

Product Version: UE 4.9
more ▼

asked Dec 08 '15 at 03:10 AM in Using UE4

avatar image

10 3 7 11

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Hi yeeen, To allow your NPC to hear something, you can add a Ai Perception Compoennt to your AIController and add one AI Hearing config to Senses Config array.

alt text

Then, you can implement the OnPerceptionUpdated of this component and using the Get Actor Perception method get the info of the character that has maked noise. (in my example i am using 1 as index because i have two Senses config, and the index 0 is for AI Sight config). In this simple example i draw a degbug sphere in the location of the noise.

alt text

Then, your Player can generate some noise using Make Noise node.

Now, if you want that your NPC walk to the noise location, you can simply replace the debug node for a Move To Location Node or even better, save the noise location in some blackboard key and then use the behavior tree and the Move To Node.

Also, remember to add to your level a Nav Mesh Bounds Volumen because you need it for all the Move To functions of your NPC.

Best regards

more ▼

answered Dec 08 '15 at 04:45 AM

avatar image

502 23 13 38

avatar image nan2cc Dec 08 '15 at 04:48 AM

This can be some very simple example of the branch of your BT to execute when your character hear some noise, asuming that the EnemyLastLocationKey store your Noise Location.

alt text

avatar image kumoshiroi Dec 08 '15 at 11:10 AM

nan2cc how did you "fusion" "Break ActorperceptionInfo" with "Get actors perception" and "get" with "Break AiStimulus" please? I had no idea the index was for the sense used this is really usefull! Thank you!

avatar image nan2cc Dec 08 '15 at 01:10 PM

Sorry kumoshiroi, i dont understand exactly what is your problem, also my english is so bad, sorry about that :) . . . please, send me a screenshot of your blueprint and i can review it. On the other hand, as you can see in the first imagen. My AI Perception Component has two elements inside the Sense Config array. The first element is AI Sight config, this is the index 0, you can get the info regard this sense using index 0 in the array returned by Get Actor Perception. And the second element inside Sense Config is for AI Hearing sense, and you can get it using index 1. If you only need one kind of sense, you can add only one element, for example, AI Sight config and always use index 0.

Best regards

avatar image kumoshiroi Dec 08 '15 at 01:16 PM

No problem! :) i was just wondering how you merged nodes together, see my pictures. (i am using 4.10 maybe it looks different in other version)alt text Thank you!

merge node.png (153.7 kB)
avatar image nan2cc Dec 08 '15 at 01:24 PM

Ohh i see . . . you do not have a problem, you can continue your blueprint with a Branch Node with Successfully Sensed as condition and you will see another "port" to fusion from Get ACtors Perception to that Branch and continue as my example, the only different is that i'm not using the Break node, i directly select, for example, from Get Actors Perception node, the Info output, right click and select Split, also the same for Get. Is like a shortcut to break structs ;).

Best regards

avatar image kumoshiroi Dec 08 '15 at 01:27 PM

Thank you very much! :D

avatar image yeeen Dec 09 '15 at 06:45 AM

This is my problem, my target location appears as invalid. How can I resolve this? :( Thank you in advance

behavior tree.png (168.1 kB)
avatar image nan2cc Dec 09 '15 at 01:20 PM

Hi yeeen, show me your AgroCheck Service, I suppose that you set TargetToFollow in that Service and probably something is going wrong in that Service and TargetToFollow I not being setted.

Best regards

avatar image yeeen Dec 10 '15 at 01:15 AM

Here it is.

argocheck.jpg (28.4 kB)
avatar image nan2cc Dec 10 '15 at 01:23 AM

Hi yeeen, this are the properties of your service, but i need to see the Blueprint in order to review it and see if something is wrong.

avatar image yeeen Dec 10 '15 at 01:32 AM

Here it is. I crop it in 3 parts.

1_argocheck.jpg (206.3 kB)
2_argocheck.jpg (213.3 kB)
3_argocheck.jpg (101.1 kB)
avatar image nan2cc Dec 10 '15 at 01:42 AM

The problem in your blueprint is that after Event Receive Tick AI you Cast To AI_Controller and set the AIConRef var, but then you dont do anything more. Check that the “output port” from Set AIConRef node is unplugged. Connect the “output port“ from Set AIConRef node to the “input port“ in Get All Actors of Class node.

Try it, and let me know if it work.

avatar image yeeen Dec 10 '15 at 03:03 AM

Hi nan2cc, it really doesn't work :( I double check everything and review the tutorial from UE4 but still the other character doesn't chase my character.

(comments are locked)
10|2000 characters needed characters left
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