Variable is Not Clearing When Actor Destroyed

I’m trying to get some communication between two objects so the victim object can tell the attacking object it is dead.

Currently, I grab the actor component from a mouse click, then use that actor variable to call apply damage and do that. When the victim is destroyed, I expected the variable that was holding the victim’s actor to become invalid since that actor was no longer on the map. That doesn’t seem to happen. Even though the actor is destroyed and no longer in the world, the variable is still holding that actor. I was using the IsValid? event to control whether my attacking unit should decide if it needs to keep attacking.

So my question is, how can I send information from a dying unit to the attacking unit to tell it to clear a variable (or change one)? I can’t cast to a specific blueprint because I need it to be dynamic (RTS units need to be dynamic) and I can’t use global variables because that won’t work for tons of little units attacking each other.

Hey FragHatter-

You should be able to add a reference variable to your victim inside the attacking unit’s blueprint. Then have the victim check itself for if it is valid or not. For instance, once HP is 0 have the victim set his own IsValid variable to false. Then when the attacker checks the reference and it is false, stop attacking.

Cheers