# UE5.3 C++: OnTargetPerceptionForgotten Delegate not Firing

**URL:** <https://forums.unrealengine.com/t/ue5-3-c-ontargetperceptionforgotten-delegate-not-firing/1786713>\
**Category:** Programming & Scripting\
**Tags:** Perception, unreal-engine, question\
**Created:** [April 3, 2024, 8:48pm UTC](https://forums.unrealengine.com/t/ue5-3-c-ontargetperceptionforgotten-delegate-not-firing/1786713 "2024-04-03T20:48:11Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![TheSilver812](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/thesilver812/32/549763_2.png) [@TheSilver812](https://forums.unrealengine.com/u/TheSilver812)\
**Post date:** [May 28, 2024, 10:10pm UTC](https://forums.unrealengine.com/t/ue5-3-c-ontargetperceptionforgotten-delegate-not-firing/1786713/9 "2024-05-28T22:10:18Z")

</div>

After much digging, I finally solved your (our) problem!

The problem with setting bForgetStaleActors with the GetCurrent() method in BeginPlay is that by then it’s too late to actually matter.

You see, the UAIPerceptionComponent class does not use bForgetStaleActors from UAISystem, but it’s own bForgetStaleActors that it sets on its constructor with this line:

```auto
bForgetStaleActors = GET_AI_CONFIG_VAR(bForgetStaleActors);

```

What it does is getting the value of the variable from the default object class, not the one you changed in BeginPlay.

To solve this, you can edit your DefaultEngine.ini inside the Config folder of your project and add these two lines:

```auto
[/Script/AIModule.AISystem]
bForgetStaleActors=True

```

This way, the variable will be initialized to True from the start and **OnTargetPerceptionForgotten** will work as expected.

---

_[View the full topic](https://forums.unrealengine.com/t/ue5-3-c-ontargetperceptionforgotten-delegate-not-firing/1786713)._
