AI Perception component does not detect actor destruction

So I’m using an AI to shoot at a target, destroy the target, then select a new target. The logic itself works fine as i’ve also got a movement system for the AI that when it moves it runs through and selects a new target just fine.

My issue is that I want it to select a new target when I DestroyActor the target. Unfortunatley when static the list of perceived actors updates but it does not trigger the OnPerceptionUpdated. Am I missing something? Is that meant to work this way?

That should work.
As a workaround, I would put an “isDead” boolean on the AI, and check if the current target not isDead on the BT(Behavior Tree). If it is, then it will break out and roam or something until it finds a new target.

Seems like a hack, but computers are electrified rocks we make think, so…

Hmmm well I’ve come back to this project and annoyingly I’ve got the same problem.

My AI hunts down the enemy, kills them, but when I use DestroyActor on the attacked target it dosen’t clear it out of the array. Instead it hogs the space in the array and causes problems by becoming a “null” value, meaning the search to find the next closest target is focusing on the destroyed null actor, rather than one that is alive!

You should use an array → clear node to clear out the array on death.