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
- Create a custom NPC using an NPC Character Definition and custom Verse behavior.
- Get the NPC’s npc_awareness_component.
- Subscribe to DetectTargetEvent and ForgetTargetEvent in Verse.
- Print a debug message from both event callbacks. Also print the DetectedTargets.Length in a loop
- Start a UEFN session.
- Move a player into the NPC’s detection range and confirm that DetectTargetEvent fires.
- Move the player completely outside the NPC’s detection range.
- Wait longer than the configured target age.
- 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.