[Tutorial] AIPerception Hearing 4.21

After searching for about an hour and finding only scattered answers from much older versions I finally got my own project to work with hearing. Here is a tutorial and some tips if it doesn’t work.

Tutorial:

–== The Actor emitting sound ==–

  1. Have an Actor (or pawn) to attach AIPerceptionStimuliSource component to.

  2. Select your AIPerceptionStimuliSource and in the Details pane, find your AI Perception section.
    a) Check “Auto Register as Source”
    b) In the “Register as Source for Senses” array, add an element and select “AI_Hearing”. You can also add any other senses this actor will be registered for here.

265501-add-aistimuli-sense.png

  1. Next, add a Report Noise Event to the method that will be causing noise. For instance, should a vase fall off a table it would make noise only when it hit the ground, so the Report Noise Event would follow the Hit event.

265502-add-reportnoise.png

That’s it for the Noisy Actor, now to the AI that will be hearing it.

–== The AIController ==–

  1. Find the AIPerception component in your AIController and add it.

  2. Select your AIPerception component and in its Details pane, under the AI Perception section, add an element to the Senses Config array. Select the AI Hearing Config option. You can now edit the range of hearing and other options.
    a) ** IMPORTANT ** Be sure to check all checkboxes under the Detection by Affliation tab of the Config.

265506-add-aihearingconfig.png

265507-aihearingconfig.png

  1. Finally, add the Event OnPerceptionUpdated and add the following nodes to retrieve the data on what was sensed. I simply added a PrintString node to test but this is where you logic will go for how your character will respond to hearing something. From here you can also decide on if the sound is important or not or which one takes priority.

Tips:

  1. If the AI doesn’t seem to be responding to the stimulus. Click the trashcan (Delete all elements) next to the Senses Config and add the senses again. Be sure to check all the checkboxes for Detection by Affliation.

Hope this will help alleviate some headaches, I know it alleviated mine when my little guy started hearing things! Happy crafting!!

thank you for this tutorial
couldnt find elsewhere anything like that

Just a tip for anyone in case this isn’t working – your report noise event must have an instigator or it will not be sensed by the ai perception component.