How to get a weak reference to an actor?

Hey all.

I’ve got a BP that spawns an actor. It saves the reference to the spawned Actor in a variable and uses an IsValid check on it during update. Only the IsValid always returns true, because even though the actor tries to destroy itself the reference counting (because we have a reference in our BP) keeps the thing valid.

So, how do I in blueprint store a reference to an actor such that I can do something with it ONLY if it is still valid? But without stopping it from destroying itself?

set IsValid to false just before to destroy the actor.

Having a reference to an Actor should not stop it from being destroyed. When you explicitly destroy an Actor, all ref’s to it are set to NULL.

This is in blueprint though James. So what I’m seeing is that the IsValid check always returns true, I was assuming because I still had a reference to the actor in the blueprint so it stopped the destroy, but maybe thats not the issue.

Anyway I solved it by adding a delegate bind on the destroy of the actor so I could clear out the actor reference manually. I just kind of imagined that as the Actor called destroy, the reference in the other blueprint would then become invalid (which it didn’t). Confused me a little.