Is there a event when AIPerception forgot an actor?

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.

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.

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.

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:

    virtual void HandleExpiredStimulus(FAIStimulus& StimulusStore) override;

  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!