Making a UI widget display when actor is destroyed

Hey all,

So for the last hour I’ve been trying to work this out I’ve tried everything I can think of now I’ve used Event Destroyed, Event End Play and Bind Action OnDestroyed if I load the game from a game level everything is good and I don’t get my UI appeir until the actor is destroyed (C++)
int32 DamagePoints = FPlatformMath::RoundToInt(DamageAmmount);
int32 DamageToApply = FMath::Clamp(DamagePoints, 0, CurrentHealth);

CurrentHealth -= DamageToApply;

if (CurrentHealth <= 0)
	UE_LOG(LogTemp, Warning, TEXT("Tank Death"))

return DamageToApply;

}` However when loaded from the main menu screen it instantly appeirs

Sometimes, Event Destroyed of many Actors are being called in UE4Editor (not UE4Game) on map/level load even if you don’t use it on a map / level. That’s just how the PIE (Play In Editor) works to refresh the actors in editor.

Try using a a separate custom event (i.e., OnDeathEvent) to put your UI spawn logic. And then on your HealthCheck-like event, if its life goes to 0 (dead) then call the OnDeathEvent manually (instead of Event Destroyed).

In addition, if you put UE_LOG to print “Actor Destroyed” in your Actor’s C++ Destructor method, you’ll see many actors being created and destroyed by just playing and exiting from PIE (Play In Editor).