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.
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.
Hi , 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.
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.
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
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.
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!
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
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)
Thank you!
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
Thank you very much!
This is my problem, my target location appears as invalid. How can I resolve this? Thank you in advance
Hi , 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
Hi , 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.
Here it is.
Here it is. I crop it in 3 parts.
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.
Hi , 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.