# Stimuli source vs events

**URL:** <https://forums.unrealengine.com/t/stimuli-source-vs-events/1758019>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, question\
**Created:** [March 17, 2024, 11:10am UTC](https://forums.unrealengine.com/t/stimuli-source-vs-events/1758019 "2024-03-17T11:10:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mackan1972](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mackan1972](https://forums.unrealengine.com/u/Mackan1972)\
**Post date:** [March 17, 2024, 11:10am UTC](https://forums.unrealengine.com/t/stimuli-source-vs-events/1758019/1 "2024-03-17T11:10:38Z")

</div>

Hi Unreal experts,

I have a custom AI controller I am working on, which handles sight & sound perception. Here is the code in the AI controller’s constructor, that sets this up:

```auto
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

	// Setup the sight config
	sightConfig = CreateDefaultSubobject<UAISenseConfig_Sight>(TEXT("Sight Config"));
	sightConfig->SightRadius = 3000;
	sightConfig->LoseSightRadius = (sightConfig->SightRadius + 20);
	sightConfig->PeripheralVisionAngleDegrees = 180.f;
	sightConfig->DetectionByAffiliation.bDetectEnemies = true;
	sightConfig->DetectionByAffiliation.bDetectNeutrals = true;
	sightConfig->DetectionByAffiliation.bDetectFriendlies = true;

	// Setup the hearing config
	hearingConfig = CreateDefaultSubobject<UAISenseConfig_Hearing>(TEXT("Hearing Config"));
	hearingConfig->HearingRange = 3000;
	hearingConfig->DetectionByAffiliation.bDetectEnemies = true;
	hearingConfig->DetectionByAffiliation.bDetectNeutrals = true;
	hearingConfig->DetectionByAffiliation.bDetectFriendlies = true;

	// Setup the perception component
	perceptionComponent = CreateDefaultSubobject<UAIPerceptionComponent>(TEXT("AIPerception Component"));
	perceptionComponent->OnPerceptionUpdated.AddDynamic(this, &AMerlinAIController::OnPerceptionUpdated);
	perceptionComponent->ConfigureSense(*sightConfig);
	perceptionComponent->ConfigureSense(*hearingConfig);
	perceptionComponent->SetDominantSense(sightConfig->GetSenseImplementation());

```

I have two BP actors, one that represents something visual (which has a sight-stimuli source component), and one that represents a sound (which has a hearing-stimuli source component), configured as follows, respectively:

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/8/9/0897a03bf70e82767f5ca7cf063716883bb371b6.png)

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/b/0/5b092eaf54e932bc8011fabdb43a4cba421c8af9.png)

When running the game in the editor, I can press ’ and then 4 to validate that the NPC can see the actor with visual stimuli-source (I get the green sphere around it), but I do NOT get a yellow sphere around the actor with the hearing-stimuli-source on it.

However, if I add a ReportNoiseEvent and set it to the location of the actor with hearing-stimuli-source, the NPC does “hear” it and generates a yellow sphere around the location of the noise-event.

Question 1: Am I supposed to use ReportNoiseEvent or hearing-stimuli-source? If both, then why is there no ReportSightEvent? And why even bother with stimuli-sources? It seems like there is ambiguous overlap between the event vs stimuli-source design here, or what am I missing?

Question 2: Sounds fade out over time, so how do I control the ‘max age’ of a sound?  
(I am not talking about the sound the player hears - e.g. not fading out audio volume - instead I’m concerned with destroying the ‘sound actor or component’).  
Based on what I have learned about Unreal so far (I am only a week into this), I can guess at any of the following:

a) I make custom age & maxAge properties on the actor with the stimuli-source/event/whatever and use a tick function to manually increment that age property, and when it reaches the maxAge I de-spawn/destroy the actor.

b) I could try to use the maxAge on the PerceptionComponent, but I don’t see how it would work? Why would a maxAge be on the listener? It is not the listener that fades out - it is the _source_ / the sound itself.

I think I am not understanding the intent & design of all this, so any help is greatly appreciated!

Marcus

---

<div class="post-metadata">

**Author:** ![Mackan1972](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mackan1972](https://forums.unrealengine.com/u/Mackan1972)\
**Post date:** [March 17, 2024, 11:46am UTC](https://forums.unrealengine.com/t/stimuli-source-vs-events/1758019/2 "2024-03-17T11:46:30Z")

</div>

Update - I found this thread:

> [@AI Perception Stimuli Source simply not needed?](https://forums.unrealengine.com/t/ai-perception-stimuli-source-simply-not-needed/509156):
>
> Testing with AI Perception system, it looks to me, like the AI Perception Stimuli Source Component just is not needed at all. I found this playing with Noise - it simply works with only having an AI Perception Component on the receiving side with configured senses. All actors making noise do not need the Stimuli Source at all. Found [this thread](https://forums.unrealengine.com/t/reportnoiseevent-working-on-actors-without-aiperceptionstimulisource/478648) with same observation. Now doing tests with a Sight Sense turns out, that this one also fires events without having any Stimuli Souce component added …

Whose author seems to mirror my own confusion.

I thus have to assume that hearing-stimuli sources are completely irrelevant, and one must do everything through ReportNoiseEvent (as far as hearing goes)…
