AI Perception Stimuli Source simply not needed?

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 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 at all.

Did not check source code (yet). Anyone observing the same issue? As mentioned in above thread, I did not find any single tutorial not stating, that the Stimuli Source is requred, and I don’t believe, that it is a mistake in the tutorials, because Epics AI Perception docs say:

When a stimuli source is registered, the event On Perception Updated (or On Target Perception Updated for target selection) is called which you can use to fire off new Blueprint Script and (or) update variables that are used to validate branches in a Behavior Tree.

while in reality, these events get always fired, regardless of a stimuli source. Looks more like a (documentation?) bug in my opinion.

I also tested to add a Stimuli source with no configured registered sense to check, if this might filter events, but that’s not the case.

Thank you for some thoughts on this.

1 Like

Hi, from looking at the source code, for the hearing sense the AIPerceptionStimuliSourceComponent won’t do anything there. In the AISense baseclass you have a RegisterSource function which AIPerceptionStimuliSourceComponent calls for each sense you specify, but only sight sense has that implemented. The other senses don’t, so I don’t see how having a AIPerceptionStimuliSourceComponent will matter for them. You will need it for sight sense though.

And keep in mind that by default pawns get automatically registered (you can disable that), so for them you don’t need to add an AIPerceptionStimuliSourceComponent for them to be tracked by sight sense.


Generally speaking, the senses do their work in the Update function. For hearing and damage sense that only gets called when you register an event (e.g. ReportNoiseEvent from blueprint), so those work event driven. Sight sense updates constantly though and therefore there you need to tell it which actors to keep track of.

Hi chrudimer,
thank you for your reply. Your hint about pawns getting automatically registered did finally lead me into the right direction.

If I add a stimuli component with no configured senses, the blueprint function UnregisterFromSense allows to unregister for the (unconfigured but silently registered in the background) sight sense - works perfect. Interesting observation: A UnregisterFromPerceptionSystem has no effect, while I would expect this function to be even ‘stronger’… - but at least I believe I now know, how to handle things.

Some more interesting experiment: Adding to DefaultGame.ini as found in this thread

[/Script/AIModule.AISense_Sight]
bAutoRegisterAllPawnsAsSources=false
bAutoRegisterNewPawnsAsSources=false

Once having this configured, it behaves like expected: no sight sensing happens unless the character has a StimuliSource along with the Sight sense configured. Things would be far less confusing, if this would be the default setting in the engine. At least, this should be clearly documented.

For the hearing sense, as you told, this is event driven. While this makes sense, it is really confusing, why this sense is available at all for stimuli configuration, if that configuration is completely ignored afterwards. Trying this one in DefaultGame.ini as well:

[/Script/AIModule.AISense_Hearing]
bAutoRegisterAllPawnsAsSources=false
bAutoRegisterNewPawnsAsSources=false

As expected - this just does not have influence.

I still would consider this as a bug: if I add a stimuli component and do explicitly not configure a sense, why does the system simply ignore this and register these senses silently under the hood?

Also having options available to be set and configured, it is at least extremely confusing, if these simply get ignored later on.

BTW: As for the hearing sense, I wish there was a functionaltiy not being event driven by separate make noise function, but instead driven by playing a (looping) sound cue. Let’s say chicken running around and a fox can hear them, until I use Set Volume Multiplier to make them quiet, so that the fox cannot detect them any more. Having a permanently monitored hearing sense like sight would be really helpful. But that’s another story, I will experiment with this…

Thanks a lot for pointing me into the right direction.

3 Likes

Just an update to the hearing sense: with the example chicken and fox, just starting a timer on the chicken, every second getting firing a report noise event. If Volume Multiplier is now set to a low or zero value, just pause the timer. On the fox side: AI Perception Hearing Config gets a Max Age of for example 2 seconds. Once the chicken timers get paused or sound out of reach, I get a false for Successfully Sensed in the AI Stimulus, so detecting the quiet phase works now. It’s a polling solution but looks like this works for me.