OnPerceptionUpdated Vs OnTargetPerceptionUpdated

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!

1 Like

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 =)

2 Likes