# OnPerceptionUpdated Vs OnTargetPerceptionUpdated

**URL:** <https://forums.unrealengine.com/t/onperceptionupdated-vs-ontargetperceptionupdated/485346>\
**Category:** C++\
**Tags:** aiperception, perception-component, unreal-engine, question, CPP\
**Created:** [June 25, 2021, 12:50pm UTC](https://forums.unrealengine.com/t/onperceptionupdated-vs-ontargetperceptionupdated/485346 "2021-06-25T12:50:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Umbra.Sketch](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Umbra.Sketch](https://forums.unrealengine.com/u/Umbra.Sketch)\
**Post date:** [June 25, 2021, 12:50pm UTC](https://forums.unrealengine.com/t/onperceptionupdated-vs-ontargetperceptionupdated/485346/1 "2021-06-25T12:50:05Z")

</div>

Hi,

I couldn’t find much on the differences between the two.  
From what I could gather it seems like OnTargetPerceptionUpdate seems more specific. So rather than an array, like OnPawnDetected, I have access to the most recent detected Actor? I’d like to use OnTarget… because it seems a bit more straight forward, but I don’t want to lose functionality if I’m misunderstanding how it work.

This is all assumptions on my end. Any info regarding them would be greatly appreciated. I’m currently using both of them and I don’t think I need to for my specific needs.

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![chrudimer](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/chrudimer/32/918651_2.png) [@chrudimer](https://forums.unrealengine.com/u/chrudimer)\
**Post date:** [June 25, 2021, 9:03pm UTC](https://forums.unrealengine.com/t/onperceptionupdated-vs-ontargetperceptionupdated/485346/2 "2021-06-25T21:03:00Z")

</div>

Hi, basically inside the `ProcessStimuli` function of the `AIPerceptionComponent` (which gets called in `Tick` of the `AIPerceptionSystem`) it loops through all new stimuli and calls `OnTargetPerceptionUpdated` for each of them. At the same time it adds all those actors into an array and at the end calls `OnPerceptionUpdated` with that array.

As an example imagine you have three new stimuli, (1) starts seeing actor A, (2) stops seeing actor B and (3) noise stimulus from actor B. `OnTargetPerceptionUpdated` will be called three times here, so seeing A, stops seeing B, hearing B. `OnPerceptionUpdated` would contain actor A and B.

So both will be called with the same actors, but `OnTargetPerceptionUpdated` gets called per actor and per sense and `OnPerceptionUpdated` gets called with the actors only (but you can ofc get the perception info for those actors via `GetActorInfo`).

> Any info regarding them would be  
> greatly appreciated.

By the way, since you’re already using C++ you could also take a look at the `ProcessStimuli` function of the `AIPerceptionComponent` there you can find all the information =)
