Hello. I wondering how to display Game Over widget but only when all 5 actors have been destroyed.
This imported static mash actor has NO overlap destroy actor in it however when it hits the cube it will destroy itself because of Destroy Other Actor is checked in the cube blueprint. Maybe I need to create blueprint for my 5 actors.
This actor has 4 other copies of itself though. Even if I have to create 5 different blueprints for those actors how would I go about letting UE know that all of the 5 actors have been destroyed and show Game Over widget? Either way, thanks for your much-needed help!!!
You can do it in the level BP:
You might have to set the test to something other than 0, remember the floor is probably also a static mesh actor…
This is were a custom gamemode BP would be extremely useful.
if you makes a parent class labeled something like “GameplayCounted” that parent class can have two actions on event begin play, and event destroyed.
those actions being:
on eventbeginplay - tell gamemode BP to add 1 to some float value that tracks existing important actors.
on event destroyed - tell gamemode bp to subtract 1 from that float value and check if its 0. if it is, game over.
by using this “gameplayCounted” as a parent then, you don’t have to make any changes to anything new you add or create, it will inherit this functionality from the gameplayCounted blueprint.
Since you’re already using a Destroy event, this would be fairly efficient and straighforward:
You only Get All once and simply count down as they get destroyed. This can be put anywhere, outside of the actor that you’re counting, ofc.
Why would your track it with floats? You meant integers, surely.
Interesting, is this a form of an
event dispatcher?
Yes! Actors come with a ton of dispatchers by default:
So do components (and pretty much everything else!):
All of the above are boundable (bindable?) delegates.
You will need a custom dispatcher if you need to send specific data. If you’re OK with just an actor reference in onDestroyed, it’s OK. But if you need more data from the actor, you’ll do as you do - add a custom dispatcher.
Yes, integer. My mistake.
Interesting, is this a form of an event dispatcher? I’ve only ever used custom event dispatches.