# Is there a event when AIPerception forgot an actor?

**URL:** <https://forums.unrealengine.com/t/is-there-a-event-when-aiperception-forgot-an-actor/427905>\
**Category:** AI\
**Tags:** Perception, unreal-engine, question\
**Created:** [June 22, 2018, 9:48am UTC](https://forums.unrealengine.com/t/is-there-a-event-when-aiperception-forgot-an-actor/427905 "2018-06-22T09:48:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wingedrobin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@wingedrobin](https://forums.unrealengine.com/u/wingedrobin)\
**Post date:** [June 22, 2018, 9:48am UTC](https://forums.unrealengine.com/t/is-there-a-event-when-aiperception-forgot-an-actor/427905/1 "2018-06-22T09:48:52Z")

</div>

Hi, I want to something when AIPerception component forget an actor. For example, one actor was left the perception range and the age also expired, then the AIPerception component will trigger an event to do something. Is there any good way to do like so? Or is there already defined a delegate that I can bind my event? Thanks for any advice.

---

<div class="post-metadata">

**Author:** ![PascalSantos](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@PascalSantos](https://forums.unrealengine.com/u/PascalSantos)\
**Post date:** [June 22, 2018, 12:49pm UTC](https://forums.unrealengine.com/t/is-there-a-event-when-aiperception-forgot-an-actor/427905/2 "2018-06-22T12:49:39Z")

</div>

I don’t think there is an Event for that.  
What you could do: Use ‘get known perceived actors’  
store the length. And Update it once every 0.3seconds or something.  
And if the value decreases you know that one of the actors was destroyed or expired.  
Last time I used get known perceived actors, it didnt work properly for specific senses so I’d carefully track the values with the AI Debugger before you fully integrate a feature like that.

---

<div class="post-metadata">

**Author:** ![wingedrobin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@wingedrobin](https://forums.unrealengine.com/u/wingedrobin)\
**Post date:** [June 22, 2018, 1:08pm UTC](https://forums.unrealengine.com/t/is-there-a-event-when-aiperception-forgot-an-actor/427905/3 "2018-06-22T13:08:46Z")

</div>

Hi PascalSantos,

I’d thought a solution very similar to yours, but I think to check this in tick function in each frame is not so efficient. So I came here to look for is there a better solution. If no, **maybe** I can do this in c++ myself and create a pull request to the engine repo on github.

---

<div class="post-metadata">

**Author:** ![3SanSan3](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@3SanSan3](https://forums.unrealengine.com/u/3SanSan3)\
**Post date:** [October 11, 2019, 2:09am UTC](https://forums.unrealengine.com/t/is-there-a-event-when-aiperception-forgot-an-actor/427905/4 "2019-10-11T02:09:21Z")

</div>

I was struggling with this a few months ago too, finally I have found the solution! (I’m using 4.23 now)

1. Set up your custom UAIPerceptionComponent C++ class derived from the original one.

2. Override the virtual function:

3. Do something in the cpp file! Note that you should not call Super:: method there!

4. Add your custom UAIPerceptionComponent to your AIController. That’s it!

Hopefully it helps!

---

<div class="post-metadata">

**Author:** ![7Rift](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@7Rift](https://forums.unrealengine.com/u/7Rift)\
**Post date:** [September 23, 2024, 2:24pm UTC](https://forums.unrealengine.com/t/is-there-a-event-when-aiperception-forgot-an-actor/427905/5 "2024-09-23T14:24:15Z")

</div>

The solution is simple go to the project setting, Under Engine - AI System, there is a check for “Forget Stale Actors”. Have it checked and then you can use “On Target Perception Forgotten (AI Perception)” from the AI perception component.
