How do I set up a simple “if these three actors are destroyed, then printstring/achievement pop/etc.” system in my level BP using my three actor references? Not sure how to check for destroyed, in this instance.
I’m a huge rookie so if you’re able to explain via BP, that’d be very welcome.
There’s a event called “on destroyed”.
You could try to create a interger variable to mark how many actors are destroyed.
Whenever an actor is destroyed the variable plus 1.
Until the number reach 3 you can print string for example.
Okay, thanks, I understand that (mostly). But how would I get a final “then” out of this setup? I.e., how can I plug three isvalids into a single node to verify “yes, all are destroyed, trigger achievement”?
Thank you for providing the suggestion! I understand, in concept, what you’re saying, but am having a hard time translating it to a workable blueprint. (especially when it comes to figuring out where to plug the actor references in)
Typically, the GameMode is the object that runs these kinds of things.
Create a new event in the GameMode called something like “ActorDestroyed” that increments a counter. When that counter gets to three, play a fanfare and spawn a particle system in front of the player or whatever you need to do.
Implement Event Begin Playt in GameMode to set the counter to zero.
In the destructible actor class, in event begin play, register for your own destruction event.
In the destruction event handler, get the current game mode, cast it to your gamemode subclass, and call the custom ActorDestroyed event.
If you want something fancier than a counter, you can have a list of actors to destroy in the gamemode, and in the “actor destroyed” event, look up the actor in the list, if it’s there, remove it, if the list is empty, do something.
When the destructible actors run Event Begin Play, they would look up the GameMode, and add themselves to that list.
Ahhh! Nevermind my previous comment. Just figured out (one option for) how to implement your idea. If anyone has any criticisms of this setup or spots major red flags (I don’t know the dangers of constant ticking), let me know!
Not a very scalable solution. You can just use an array instead, or get actor by class and use that array, bind all of them in the single go on BeginPlay.
Thank you! That’s what I figured, but someone else saying “everything was a red flag” made me wonder if the constant ticking would result in some catastrophic error when I package or something. I’m too green to know the consequences of actions in UE beyond what’s immediately apparent in playtesting.
It’s just bad practice in the long run. That’s all. It will work.
You will eventually run into opinions / people hating on Tick. It stems from such scripting practices. Don’t put stuff in Tick that does not belong there.
Roger that! Is there a certain quantity/complexity threshold where “on-tick” becomes dangerous? Asking since my little “three items” tick event is meant for a 10-15 min. level that exists in a single location, i.e. not much complexity.