Detecting instantly if a referenced actor is destroyed

You control whatever destroys the actor right? As the actor is destroyed, have that destruction function remove the reference in the array? “Destroy Actor>Remove Item from Array”

In a blueprint I have an array of actor references, for all kind of different actors, from custom BP classes to stock emitters. I’d like to know if any of them are destroyed at the moment (or “not long after”) they got destroyed. Right now I’m checking if any items in the array become invalid but that doesn’t work well in practice because the references stay valid for a few seconds after destruction, probably until they get garbage collected. Is there a way to tell if an actor was marked for removal?

I may or may not have control over the destruction of referenced actors. For example a particle system might destroy itself when done.

For a particle emitter that auto destroys, you have a couple options.

Use a Delay that matches the Emitter Template’s timeline.

Or make an Emitter Class actor and put the “Event Destroyed” in its event graph. Then when the emitter auto destroys itself, it should call whatever you specified.

There IsPendingKill() function but it not exposed to blueprint

So there is no way to tell from the outside if an actor was destroyed unless they implement some kind of a custom mechanic for announcing the fact.

It just isn’t going to tell you from the outside without you continually checking. So just get the return value on the spawn emitter and run a check every so often to see if it is still valid. Probably your best bet without going into C++.

Validity check works but it lags 5-10 seconds which renders it useless for my case. For now I go with actors implementing an interface for GetHealth and I keep checking that. Obviously it’s not a universal solution.

If someone really wants to instantly know if an arbitrary actor is marked for deletion then here is a hack: after Destroy() but before becoming invalid, the killed actor’s position and rotation suddenly become 0.