npc_awareness_component.ForgetTargetEvent does not fire / detected target is retained indefinitely

Summary

npc_awareness_component.DetectTargetEvent fires correctly when an NPC detects a target, but ForgetTargetEvent does not appear to fire when the target leaves sight/detection range. The target also seems to remain inside the awareness component’s detected target list indefinitely, which prevents custom NPC behavior from properly reacting to lost targets.

Please select what you are reporting on:

Verse

What Type of Bug are you experiencing?

Scene Graph

Steps to Reproduce

  1. Create a custom NPC using an NPC Character Definition and custom Verse behavior.
  2. Get the NPC’s npc_awareness_component.
  3. Subscribe to DetectTargetEvent and ForgetTargetEvent in Verse.
  4. Print a debug message from both event callbacks. Also print the DetectedTargets.Length in a loop
  5. Start a UEFN session.
  6. Move a player into the NPC’s detection range and confirm that DetectTargetEvent fires.
  7. Move the player completely outside the NPC’s detection range.
  8. Wait longer than the configured target age.
  9. Move the player back into the NPC’s sight/detection range.
  • Repeat the test by eliminating the detected agent after it has been detected.

Expected Result

After the player leaves sight/detection range and remains undetected longer than the configured target age:

  • ForgetTargetEvent should fire.
  • The target should be removed from the NPC awareness component’s detected target list.
  • When the player re-enters sight/detection range later, DetectTargetEvent should fire again.

If the detected agent is eliminated:

  • The awareness component should forget the dead/invalid target.
  • ForgetTargetEvent should fire, or the target should at least be removed from the detected target list.
  • The NPC should not keep a dead agent as an active detected target.

Observed Result

  • DetectTargetEvent fires correctly the first time the player is detected.
  • ForgetTargetEvent does not fire after the player leaves detection range and stays there long enough.
  • The awareness component appears to keep holding the original target.
  • When the player re-enters detection range, DetectTargetEvent does not fire again, apparently because the target was never forgotten.
  • If the detected agent is eliminated, the awareness component still does not appear to forget it.

Platform(s)

PC / Windows

Additional Notes

I tested this with all three awareness types:

  • Sight
  • Hearing
  • Touch

The result is the same for all of them.
Changing the Max Age value also does not appear to change the behavior.

There is also a tooltip for Max Age that says forgetting expired stimuli is controlled by AIPerceptionSystem.bForgetStaleActors in Project Settings, but that Project Setting does not appear to exist in UEFN.

After more testing, sometimes eliminating the agent triggers the ForgetTargetEvent and removes the player from the list. But also sometimes keeps the agent in the DetectedTargets and debugs the HasLineOfSight as true for the dead agent. Even if ForgetTargetEvent does trigger.
So it’s very unreliable

I found a more consistent pattern with npc_awareness_component forgetting behavior:

  • If a target dies while still in line of sight, ForgetTargetEvent fires, but the target remains in DetectedTargets.

  • If a target dies outside line of sight, ForgetTargetEvent fires and the target is correctly removed from DetectedTargets.

There is also a difference between players and NPCs:

  • If the dead target is a player, it remains in DetectedTargets and still reports HasLineOfSight = true.

  • If the dead target is an NPC, it remains in DetectedTargets, but reports HasLineOfSight = false.

But if a target simply leaves detection range, ForgetTargetEvent does not appear to fire at all, and the target remains in DetectedTargets.