UnregisterSource

When my AI and players pawns die, I call “UnregisterSource” (currently I’m also using UAIPerceptionStimuliSourceComponent so that calls UnregisterSource).
I’ve notice that in AISense_Sight, that removes any queries to the target but does not remove the source form the ObservedTargets, so queries will be re-added later (if we update the listener for example). This means that my AIs can still see the target and will continue attacking a corpse.

Also, maybe a source should be removed from RegisteredStimuliSources if it is no longer registers with any senses.

Hey Tim,

Well spotted. I guess we haven’t run into this problem ourselves only due to differences in how AI handles the perception data. The invalid queries or targets get removed as part of Sight update, but if your pawns are still there on the map, even if dead, they’re valid targets in AI sight sense. I’ll have that fixed. Thanks for reporting it!

Also, maybe a source should be removed from RegisteredStimuliSources if it is no longer registers with any senses.

My original response: I guess. On the other hand, if someone uses registration and unregistration of sources as means of toggling whether something can be perceived or not then (s)he’ll end up continuously adding and removing elements from RegisteredStimuliSources. Currently we purge RegisteredStimuliSources on a regular basis, and we’ll have to keep on doing that anyway. I don’t see much benefit in completely auto-removing elements from RegisteredStimuliSources until those sources could come back.

After contemplating related code a bit: You’re right, once a source has been removed from all senses we should remove it. Also, UAIPerceptionSystem::UnregisterSource removes self from SourceActor.OnEndPlay overzealously - this should be done only when source gets removed from all senses as well. I’ll have those fixed as well. Thanks a lot!

Cheers,

–mieszko